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

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -