c++11 - Typedef of a templated alias in C++ -


i have following template class a:

template<template<typename>class vectort> class {       //... } 

which instantiate this: a<mystdvector> objecta; mystdvector alias std::vector specific allocator (myallocator):

template<typename t> using mystdvector = std::vector<t,myallocator> 

i decided create alias named vector inside a:

template<template<typename>class vectort> class {  public:       template<typename t>       using vector = vectort<t>;        //... } 

such inside a can call vector<int> (instead of vectort<int>). more important, access alias vector class b. how achieve this :

template<class a> class b { public:     // how define type vector refers a::vector      // such inside b, vector<int> refers a::vector<int>     // refers mystdvector<int>  }    

in order create attribute vector<int> in class b instance. have tried 3 things (inside class b):

typedef typename a::vector vector;   //1  template<typename t> using vector = typename a::vector;   //2  template<typename t> using vector = typename a::vector<t> //3 

but compiler says typename a::vector names stdvector not type (i guess considered alias , not type?) 2 first solutions. , last solution produces syntax error.

here whole code tried compile :

#include <vector>  template<typename t> using mystdvector = std::vector<t/*,myallocator*/>;  template<template<typename>class vectort> class { public:     template<typename t>     using vector = vectort<t>;      //... };  template<class a> class b { public: //    typedef typename a::vector vector;   // 1  //    template<typename t> //    using vector = typename a::vector;   // 2  //    template<typename t> //    using vector = typename a::vector<t>; // 3      vector<int> m_vector; };  int main(int argc, char *argv[]) {     a<mystdvector> a;     b<a<mystdvector>> b;     return 0; } 

i confused difference between typedef , alias, when want mix them , templated...

type 3 adding template

template <typename t> using vector = typename a::template vector<t>; 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -