Reputation: 602
On expression:
typedef RDOCalcUnary<RDOValue, (&RDOValue::operator-), OperatorType::OT_ARITHM> RDOCalcUMinus;
gcc shows the following errors:
error: ‘rdoRuntime::RDOValue::operator-’ cannot appear in a constant-expression
error: ‘&’ cannot appear in a constant-expression
error: template argument 2 is invalid
error: invalid type in declaration before ‘;’ token
Under Windows the MSVC compiler compiles the code without errors.
What's the problem? How do I fix this?
template <typename ret_type, ret_type (RDOValue::*pOperator)() const, typename OperatorType::Type CalcType>
class RDOCalcUnary: public RDOCalcUnaryBase
{
friend class rdo::Factory<RDOCalcUnary<ret_type, pOperator, CalcType> >;
public:
enum { calc_type = CalcType };
typedef ret_type (RDOValue::*value_operator)() const;
static RDOSrcInfo getStaticSrcInfo(CREF(RDOSrcInfo::Position) position, CREF(LPRDOCalc) pUnaryCalc);
static value_operator getOperation ();
protected:
RDOCalcUnary(CREF(RDOSrcInfo::Position) position, CREF(LPRDOCalc) pOperation);
private:
REF(RDOValue) doCalc(CREF(LPRDORuntime) pRuntime);
};
Upvotes: 2
Views: 349
Reputation: 26
When you do the typedef don't use brackets:
typedef RDOCalcUnary<RDOValue, &RDOValue::operator-, OperatorType::OT_ARITHM> RDOCalcUMinus;
It works to me.
Upvotes: 1