Re: template typedef



"Alessandro Vergani" <avergani@xxxxxxxxxxx> wrote in message
news:4FC7D387-AA48-4DCC-9138-ED2387A7811B@xxxxxxxxxxxxx
suppose I have a template class like:

template <typename T>
struct X
{
T value;
};

If I need a shared_ptr to this class I declare it like:

std::tr1::shared_ptr<X<char>> XcharPtr;

Is there a way to typedef the first part, so I can do something like:

typedXptr<char> XcharPtr;

There will be, in the next version of the standard. For now, the closest
you can get is something like this:

template <typename T>
struct typedXptr {
typedef shared_ptr<X<T> > type;
};

typedXptr<char>::type XcharPtr;

--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Dealing with ad hominem attacks in comp.programming
    ... template <int N, int D> ... typedef rationaltype; ... template <typename Lhs, typename Rhs> ...
    (comp.programming)
  • Re: function template
    ... > I was working with a simple function template to find the min of two values. ... struct Promote ... template struct Promote{typedef unsigned long ... template struct Promote{typedef int ...
    (comp.lang.cpp)
  • Re: Stable priority queue
    ... > If a 5GHz computer had an integer increment that took only one CPU cycle ... We could also use the sizeof trick though, which is a cool use of template ... struct typelist ... typedef T car; ...
    (comp.lang.cpp)
  • Re: SFINAE compiler problem?
    ... struct myclass ... myclass& f1 ... template <typename T, typename X> ...
    (microsoft.public.vc.language)
  • Reprise: Template syntax help
    ... Comeau produces this error: ... ".template" construct is needed somehow. ... struct foo_t ... template <typename T> ...
    (comp.lang.cpp)