c++ - [Bug report] Overloading on variable arguments.
- Daniel James (31/33) Aug 24 2004 The 'official' implementation of boost::is_convertible works by
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