I'm still trying to migrate from MSVC to GCC, but I can't seem to find a solution to the following problem:
template < typename A, typename B, typename C, typename D >
class Test
{
public:
Test (B* pObj, C fn, const D& args) : _pObj(pObj), _fn(fn), _args(args)
{
}
A operator() ()
{
return _args.operator() < A, B, C > (_pObj, _fn); // error: expected primary-expression before ',' token
}
B* _pObj;
C _fn;
D _args;
};
Please help!
This typically means that your code is missing a closing '}'. For every opening '{' there should be a closing '}' expected primary-expression before ')' token. Sometimes this happens when the variable passed into a function isn't the type the function expected.
Primary expressions are the building blocks of more complex expressions. They may be literals, names, and names qualified by the scope-resolution operator ( :: ). A primary expression may have any of the following forms: primary-expression.
Try return _args.template operator() < A, B, C > (_pObj, _fn);
.
Without the template
keyword the parse would be different. Without that extra use of template
, the compiler does not know that the less-than token (<) that follows is not really "less than" but the beginning of a template argument list.
14.2/4
When the name of a member template specialization appears after . or -> in a postfix-expression, or after nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template. Otherwise the name is assumed to name a non-template.
P.S: Read this Stackoverflow FAQ Entry
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With