Sign in to follow this  
Amma

[C++] typedef templates

Recommended Posts

Amma    130
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
XXX_Andrew_XXX    340
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
Nemesis2k2    1045
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this