Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #83869

Uniform initialization ambiguity

From Juha Nieminen <nospam@thanks.invalid>
Newsgroups comp.lang.c++
Subject Uniform initialization ambiguity
Date 2022-04-29 07:56 +0000
Organization Aioe.org NNTP Server
Message-ID <t4g5no$raf$1@gioia.aioe.org> (permalink)

Show all headers | View raw


Suppose you have this overloaded function:

    void foobar(const std::string&);
    void foobar(const std::vector<int>&);

and you try to call it like:

    foobar({});

you'll rather obviously get a compiler error because the call is ambiguous.
There's no way for the compiler to know which one you want to call.

However, if the functions were instead like this:

    void foobar(const std::string&);
    void foobar(int);

now that 'foobar({});' will compile just fine (at least with gcc), and
call the foobar(int) function. How so? Why is there no ambiguity here?

Back to comp.lang.c++ | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Uniform initialization ambiguity Juha Nieminen <nospam@thanks.invalid> - 2022-04-29 07:56 +0000
  Re: Uniform initialization ambiguity Öö Tiib <ootiib@hot.ee> - 2022-04-29 06:29 -0700
    Re: Uniform initialization ambiguity "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-04-29 19:30 +0200
    Re: Uniform initialization ambiguity Juha Nieminen <nospam@thanks.invalid> - 2022-04-29 19:54 +0000
  Re: Uniform initialization ambiguity Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-29 08:42 -0700
    Re: Uniform initialization ambiguity Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-04-29 08:48 -0700

csiph-web