Template class is not exported from WinRT Component
-
Tuesday, May 15, 2012 10:32 PM
The following code attempts to create and export a template class from a WinRT component dll. This code compiles fine, but the class is not visible in a C# Metro consumer application. Why?
template<typename T> public ref class TemplateClass sealed { private: T _item; public: TemplateClass(){_item = nullptr;} public: TemplateClass(T item) { _item = item } public: T Test() { return _item; } }; public ref class NonTemplateClass sealed { private: int _value; public: NonTemplateClass() {} public: NonTemplateClass(int value) { _value = value; } public: int Test() { return _value; } };
All Replies
-
Wednesday, May 16, 2012 8:24 AMModerator
Hello,
Thanks for your feedback, I will involve more experts to investigate it.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
-
Friday, August 10, 2012 7:14 PMWere you able to involve enough experts to find a solution?
-
Monday, August 13, 2012 11:20 PM
Public template classes are not allowed in C++/CX.
The code compiled due to a bug in RC. With the RTM compiler, you will get an error:
1>app.xaml.cpp(33): error C3401: 'Foo' : invalid assembly access specifier - only 'private' is allowed on class templates
Marian Luparu
Visual C++
- Marked As Answer by BullyOwner Tuesday, August 14, 2012 1:54 AM
-
Saturday, August 25, 2012 5:13 PM
I just finished watching a Build2011 video that explains how "Generics" are essentially Templates. I suspect you'll feel right at home with Generics as they seem identical to templates.
http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-532T offset: 00:32:00 Generics
MCAD.NET C# - http://www.Global-webnet.com/Blog


