Extern template tweaks
Document extern template functions support. Extern templates result in new warning to differentiate from template explicit instantiation definition warning.
This commit is contained in:
parent
40b8416213
commit
017900d57e
8 changed files with 89 additions and 16 deletions
|
|
@ -0,0 +1,24 @@
|
|||
%module xxx
|
||||
|
||||
%inline %{
|
||||
namespace std {
|
||||
template<typename T> class vector {};
|
||||
}
|
||||
template<typename T> void Func() {}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
// Class template
|
||||
template class std::vector<int>; // C++03 template explicit instantiation definition in C++
|
||||
extern template class std::vector<int>; // C++11 template explicit instantiation declaration (extern template)
|
||||
%}
|
||||
%template(VectorInt) std::vector<int>; // SWIG template instantiation
|
||||
|
||||
%inline %{
|
||||
// Function template
|
||||
template void Func<int>(); // C++03 template explicit instantiation definition in C++
|
||||
extern template void Func<int>(); // C++11 template explicit instantiation declaration (extern template)
|
||||
%}
|
||||
%template(FuncInt) Func<int>; // SWIG template instantiation
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
cpp_template_explicit_instantiation.i:12: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_explicit_instantiation.i:13: Warning 327: Extern template ignored.
|
||||
cpp_template_explicit_instantiation.i:19: Warning 320: Explicit template instantiation ignored.
|
||||
cpp_template_explicit_instantiation.i:20: Warning 327: Extern template ignored.
|
||||
Loading…
Add table
Add a link
Reference in a new issue