www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - [Bug report] Overloading on variable arguments.

The 'official' implementation of boost::is_convertible works by 
overloading on the ... operator. I managed to come up with a workaround 
which seems to work fine and has been accepted into boost, so this isn't 
particularly important.

Anyway, David Abrahams wrote:

 It's pretty simple.  a (...) parameter is always a worse match than
 anything else that matches, including template parameter types.

In the Digital Mars compiler it seems to be equal to certain user-defined conversions. All the overloads in the following code should not be ambiguous: #include <cassert> struct convertible_to_char { operator char() { return 0; } }; struct convertible_from_char { convertible_from_char(char) {} }; struct any_conversion { template <typename T> any_conversion(const volatile T&) {} }; void check1(any_conversion ...) { assert(0); } void check1(float, int) {} void test1() { convertible_to_char x; check1(x, 0); } void check2(any_conversion ...) { assert(0); } void check2(convertible_from_char, int) {} void test2() { float x = 0; check2(x, 0); } void check3(...) { assert(0); } void check3(char) {} void test3() { convertible_to_char x; check3(x); } void check4(...) { assert(0); } void check4(convertible_from_char) {} void test4() { char x = 'a'; check4(x); } int main() { test1(); test2(); test3(); test4(); }
Aug 24 2004