samedi 4 avril 2015

Replacing class name with an alias

C++11 type alias is great and I use it a lot but recently I've been wondering why type aliasing doesn't work like such #include



template<typename T>
class Y
{
public:
Y(): t( T{} ) {}
T getT() const;

private:
T t;
};

template< typename T>
using Foo = Y<T>;


template< typename T>
T Y<T>::getT() const { return t; } //FINE

/* NOT FINE!
template< typename T>
T Foo<T>::getT() const { return t; }
*/

int main()
{
Y<int> f{};
return 0;
}


Question: If a type is aliased, why can't we replace the type aliased with the new alias name?


Aucun commentaire:

Enregistrer un commentaire