English 中文(简体)
Nest 出口
原标题:Nested class, dllexport and VS2010

让我们有以下法典:

template <typename T> struct X
{ X() { }
};

struct __declspec(dllexport) A
{ struct __declspec(dllexport) AB
  { int i;
  };

  typedef X <AB> XAB;

  //template struct __declspec(dllexport) X <AB>; // error C2252: an explicit instantiation of a template can only occur at namespace scope

  static XAB x; // warning C4251:  A::x  : struct  X<T>  needs to have dll-interface to be used by clients of struct  A 
  static X <AB> x2; // warning C4251:  A::x2  : struct  X<T>  needs to have dll-interface to be used by clients of struct  A 
  X <AB> x3; // warning C4251:  A::x3  : struct  X<T>  needs to have dll-interface to be used by clients of struct  A 
};

template struct __declspec(dllexport) X <A::AB>; // Has no effect

因此:

  • I have a class to be exported to a DLL.
  • This class has a subclass to be exported to the DLL, too.
  • There are variables ( x... ) of type template <subclass>.
  • The member variables need to be dll-exported, too.
  • So I d need to instantiate explicitly the template <subclass> before this type is used.
  • But this is not possible as instantiation may be done only in the global scope.
  • But in the global scope, the subclass is not defined (yet).

  • The template <class:subster> Immediateiation after the category body has no effect.

因此,如何正确处理这一问题,以避免任何警告和错误?

BTW:在VS2008年,该类中模板的证实工作良好。

事先感谢你。

LuP

问题回答

暂无回答




相关问题
Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

How to create a submit button template in Oracle APEX?

I m trying to create a template for a button in Oracle APEX but I don t seem to have access to the appropriate substitution strings to make it work. For non-templated buttons APEX seems to insert a ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Load ruby on rails template from database

I wonder if there is a way for me to store ruby on rails view files into database store and have that fetched directly from there. The reason is I want to create a CMS with all the user data stored in ...

Templated HTML Editor

I m looking for a HTML editor that kinda supports templated editing or live snippets or something like that. Background: I m working on a website for a friend. As there are no specifications what the ...

Dreamweaver changing path to site s reference instead of local

I have noticed recently, when I apply a template to a new HTML website, all the relative paths are pointed to my local files, example: file:///C|/webstuff/files but I cannot set them to relative paths ...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签