• Advertisement
Sign in to follow this  

[C++] typedef templates

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Are typedefed templates supported in recent compilers? Eg. template<typename T> typedef std::vector<T, std::allocator<T> > bag_of<T>; doesn't work in MSC++ 7, shouldn't it?

Share this post


Link to post
Share on other sites
Advertisement
i'm pretty sure the c++ standard doesn't allow typedef templates.

Share this post


Link to post
Share on other sites
No, support for template typedefs wasn't added to the standard in the end. Recent trends in template use seem to show it really isn't that necessary.

This is a little more typing perhaps, but similar enough:


template<class T>
struct bag_of { typedef std::vector<T,std::allocator<T> > type; };

bag_of<int>::type b;

Share this post


Link to post
Share on other sites
As mentioned, the C++ standard doesn't include templated typedefs. It's one of the things I'm hoping will be included in the next update of the standard.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement