开发者

Default template parameters?

开发者 https://www.devze.com 2023-04-11 04:20 出处:网络
I am currently trying to make an old project in C++ work with more recent tools: the project has been developped on Windows XP with VC71 and I am now trying to make it run on Windows 7 with VC100.

I am currently trying to make an old project in C++ work with more recent tools: the project has been developped on Windows XP with VC71 and I am now trying to make it run on Windows 7 with VC100.

I didn't get any "big" 开发者_开发百科problem yet but however I am having a last compilation issue which led me to some code - pretty obscure to me -.

Here is a sample of the macro (simplified) I am having trouble with:

#define IMPORT_STD_PAIR( _keyClass_ ,_objectClass_)               \
 extern template struct std::pair< _keyClass_,_objectClass_ >;    \
 ...

The error is:

C2955: 'std::allocator' : use of class template requires template argument list.

I don't really get what it is supposed to do (the 2nd line), specify default parameters to a templated class ?

Thank you for your help.

Edit: @Mark B: Thank you for you answer. You made me realize what was going on: Nothing.

In fact, it is my fault cause I am not familiar at all with developping on Windows. The code was originally:

#define IMPORT_STD_MAP( _import_directive_, _keyClass_ ,_objectClass_) \
  extern template struct _import_directive_ std::pair<_keyClass_,_objectClass_>;    

I neglected _import_directive_ cause it was almost "empty" in every case but one. So when it is empty, it simply creates an instance with no name which is not really relevant; but when this macro takes the value __declspec ( dllimport ) it makes much more sense :)

Thanks for helping me realizing that, I thought it was something more exotic, and thank you for the debugging advice which has been useful.


It looks like ListRemake is a templated class and you're trying to instantiate an instance as

ListRemake myList;

You need to specify the template arguments for ListRemake

ListRemake<int, long> myList;


It looks like it's attempting to instantiate a specific instantiation of std::pair. Without more context I can't see why this would be attempted, but you might try just making the macro define to nothing and see if the code compiles, links, and appears to work. They may have changed template compiling in 10.0.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号