c++ - Overload reference conversions -
the following class seems compile, conversion operators never called:
class { public: operator a() const { std::cout << "a() called" << std::endl; return *this; } operator a&() { std::cout << "a&() called" << std::endl; return *this; } operator const a&() const { std::cout << "const a&() called" << std::endl; return *this; } };
is function specifying conversion reference ignored?
here's quote 12.3.2
a conversion function never used convert (possibly cv-qualified) object (possibly cv-qualified) same object type (or reference it)
also, using -wall -wextra -pedantic -ansi
on gcc gave me: warning: statement has no effect
static cast. (also, try clang online give nice compiler error messages).
Comments
Post a Comment