typename

    18热度

    2回答

    据我了解,在C++ 0x中模板的别名将使我们能够做到以下几点: template <typename T> using Dictionary = std::map< std::string, T >; Dictionary<int> ints; ints[ "one" ] = 1; ints[ "two" ] = 2; 我有两个问题: 首先,我们能够做到这一点(绑定到任何类型的,或者

    1热度

    1回答

    以下无法对其进行编译(在Linux的gcc 4.2.1,反正): template< typename T > class Foo { public: typedef int FooType; }; void ordinary() { Foo<int>::FooType bar = 0; } template< typename T > void te

    1热度

    2回答

    可能重复的目的: Officially, what is typename for? 当我使用 template <typename TMap> typename TMap::referent_type * func(TMap & map, typename TMap::key_type key) { ... } 什么是两者的目的“类型名“在第二行? 它似乎会触发编译时警告(VS2008:

    3热度

    3回答

    我有这样 template< typename T > class vector { public: typedef T & reference; typedef T const & const_reference; typedef size_t size_type; const_reference at(size_t) const;

    4热度

    2回答

    我有一个小模板类包含一个boost :: intrusive_ptr内式储物柜的,我想存储一个std ::地图里: template <typename T> bool LockerManager<T>:: AddData(const std::string& id, T* pData) { boost::intrusive_ptr<Locker<T> > lPtr(Lo

    20热度

    1回答

    下面的模板特码: template<typename T1, typename T2> void spec1() { } 测试案例1: template< typename T1> //compile error void spec1<int>() { } 测试案例2: template< typename T2> //compile error void spec1<i

    5热度

    1回答

    template <class T> struct ABC { typedef typename T* pT; }; int main(){} 上面这段代码提供了错误 expected nested-name-specifier before 'T' expected ';' before '*' token 什么是错的代码示例?

    2热度

    3回答

    我有一个类看起来像这样: #include <vector> #include "record.h" #include "sortcalls.h" template< typename T, template<typename , typename Allocator = std::allocator<T> > class Cont = std::vector> cl

    3热度

    4回答

    我已经习惯了写模板是这样的: template<typename T> void someFunction(SomeClass<T> argument); 但是 - 现在我遇到的模板写成这样另一个线程: template<U> void someFunction(SomeClass<U> argument); 据我所知可以互换使用“typename”和“class”(除了关于嵌套类型的

    0热度

    2回答

    可能重复: Why do I need to use typedef typename in g++ but not VS? 你好,最近我占与VC++代码移植到GCC /英特尔的 “简单问题”。 的代码编译W/O错误在VC++: #include <vector> using std::vector; template <class T> void test_vec(std::vector