Code compiles fine yet is marked as erroneous
-
The bottom line in the following code from the Urho3D Game Engine is marked as erroneous:
template <class T> class ObjectFactoryImpl : public ObjectFactory { public: /// Construct. ObjectFactoryImpl(Context* context) : ObjectFactory(context) { type_ = T::GetTypeStatic(); baseType_ = T::GetBaseTypeStatic(); typeName_ = T::GetTypeNameStatic(); } /// Create an object of the specific type. virtual SharedPtr<Object>(CreateObject()) { return SharedPtr<Object>(new T(context_)); } };
expected '}' got 'return'
It compiles just fine though, should this be reported as a bug in QtCreator or magic? -
Hi and welcome to devnet,
I might be wrong, but the signature of CreateObject is unusual for a function declaration. It should rather be
virtual SharedPtr<Object> CreateObject() { return SharedPtr<Object>(new T(context_)); }
-
That looks more familiar. Thanks for the clarification.