1 2 3 4 5 6 7 8 9 | class BClass {}; template <typename Type> class AClass { public: virtual const Type aMethod() const { return Type(); } }; int main() { return AClass<BClass const&>().aMethod() ,0; } |
Y2xhc3MgQkNsYXNzIHt9OwoKdGVtcGxhdGUgPHR5cGVuYW1lIFR5cGU+IGNsYXNzIEFDbGFzcyB7CiAgcHVibGljOgogIHZpcnR1YWwgY29uc3QgVHlwZSBhTWV0aG9kKCkgY29uc3QgeyByZXR1cm4gVHlwZSgpOyB9Cn07CmludCBtYWluKCkgewogIHJldHVybiBBQ2xhc3M8QkNsYXNzIGNvbnN0Jj4oKS5hTWV0aG9kKCkgLDA7Cn0=
prog.cpp: In member function 'const Type AClass<Type>::aMethod() const [with Type = const BClass&]': prog.cpp:8:42: instantiated from here prog.cpp:5:52: error: invalid value-initialization of reference types
-
result: Compilation error (maybe you wish to see an example for C++11)


