This code unexplicably doesn't compile:
struct sometype
{
template <typename T>
T* get() { return nullptr; }
};
template <typename T>
struct anothertype
{
#if 1
template <typename T2> struct some_wrapper { typedef T2 type; };
typedef typename some_wrapper<sometype>::type thetype;
#else
typedef sometype thetype;
#endif
typedef thetype* Ptr;
Ptr m_ptr;
T* get() { return m_ptr->get<T>(); }
};
If I change the #if
argument to 0, it is somehow fixed. Can somebody shed some light in this? Please note that the apparently pointless some_wrapper
thing actually does something useful in my real code.
I'm using g++ 4.7.1 with -fstd=gnu++11
, the error is as follows (pointing to the line where I declare anothertype<T>::get
:
error: expected primary-expression before '>' token
error: expected primary-expression before ')' token
It's tough to tell with all your typedefs, but I'd wager you need:
m_ptr->template get<T>();
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