lundi 29 août 2016

typedef to alias of template template

I got a traits class, AttributeTraits, that uses a smart-pointer template class, MySmartPointer :

template<typename T>
class MySmartPointer {};

template<template <typename> class SP = MySmartPointer>
struct AttributeTraits {
    template <typename T>
    using SmartPointerClass = SP<T>;
};

AttributeTraits use alias to hold the template class it have. Now, I need that Attribute class that gets a trait class will use a typedef/alias to the smart pointer class, such:

template <typename Traits>
struct Attribute {
    typedef typename Traits::SmartPointerClass<int> SmartPointerType; // error: non-template 'SmartPointerClass' used as template
    using SmartPointerType2 = typename Traits::SmartPointerClass<int>; // error: expected ';' before '<' token
    using SmartPointerType3 = Traits::SmartPointerClass<int>; // error: non-template 'SmartPointerClass' used as template
};

But none of the 3 options above works...

Aucun commentaire:

Enregistrer un commentaire