我typedef该template class怎么办?就像是:
typedef std::vector myVector;  // <--- compiler error
我知道两种方式:
(1) #define myVector std::vector // not so good
(2) template<typename T>
    struct myVector { typedef std::vector<T> type; }; // verbose
我们在C++ 0x中有更好的东西吗?
而不是使用
std::vector<Object> ObjectArray;
我希望它是
MyArray<Object> ObjectArray;
保留所有std :: vector方法.(比如push_back(),reserve(),...等)
但是,使用
typedef std::vector MyArray;
不行.我应该使用模板吗?怎么样?
我有一个模板课
template <T>
class Example 
{
...
};
其中有许多以下类型的方法:
template <class U> <class V> method(....)
在这些内部我使用tr1 :: shared_ptr到U或V或T.
它繁琐的打字tr1::shared_ptr<const U>或tr1::shared_ptr<const V>.
显而易见的事情:
template <typename U>
typedef tr1::shared_ptr<U> shptr<U>;
不起作用.
你在这种情况下做了什么?什么能减少冗长的东西?