Questo codice unexplicably non può essere compilato:C++ argomento modello di funzione con il tipo struct su modelli woes
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>(); }
};
Se cambio l'argomento #if
-0, è in qualche modo risolto. Qualcuno può far luce in questo? Si prega di notare che la cosa apparentemente inutile some_wrapper
effettivamente fa qualcosa di utile nel mio codice reale.
sto usando g ++ 4.7.1 con -fstd=gnu++11
, l'errore è la seguente (indicando la linea in cui dichiaro anothertype<T>::get
:
error: expected primary-expression before '>' token
error: expected primary-expression before ')' token
Se si esegue esattamente il codice che è stato inviato tramite il compilatore, si ottiene questo errore? –
@ DavidRodríguez-dribeas http://ideone.com/N8dQoj (esattamente il codice della domanda) – leemes