ARTICLE AD BOX
In the following C++ code (compiled with g++ 10.2.0), the declaration of myManager_not_ok produces the error:
error: deduced class type ‘Manager’ in function return type
while the other, quasi-identical, declarations do not. Does this mean that myManager_not_ok(Delegate(parameter)) is interpreted as a function definition? If so, why and how, and why are the other instances of Manager accepted?
Is this a C++ feature or a g++ problem?
class Delegate { public: Delegate(int parameter) {} }; template<typename T_DelegateClass> class Manager : T_DelegateClass { public: Manager (T_DelegateClass theDelegate) : T_DelegateClass(theDelegate) {} }; int parameter=052; Manager myManager_not_ok( Delegate(parameter) ); // results in error Manager myManager_ok( Delegate( 052) ); Manager myManager_ok2( Delegate( (int)parameter) );Compiled with
g++ -std=c++17 deduced_class_type_in_function_return_type.cpp