1 #include "cxx-templates-common.h" 2 3 namespace hidden_specializations { 4 // explicit specializations 5 template<> void fn<int>() {} 6 template<> struct cls<int> { 7 void nested_fn(); 8 struct nested_cls; 9 static int nested_var; 10 enum nested_enum : int; 11 }; 12 template<> int var<int>; 13 14 // partial specializations 15 template<typename T> struct cls<T*> { 16 void nested_fn(); 17 struct nested_cls; 18 static int nested_var; 19 enum nested_enum : int; 20 }; 21 template<typename T> int var<T*>; 22 23 // member specializations 24 template<> void cls<void>::nested_fn() {} 25 template<> struct cls<void>::nested_cls {}; 26 template<> int cls<void>::nested_var; 27 template<> enum class cls<void>::nested_enum { e }; 28 template<> template<typename U> void cls<void>::nested_fn_t() {} 29 template<> template<typename U> struct cls<void>::nested_cls_t {}; 30 template<> template<typename U> int cls<void>::nested_var_t; 31 32 // specializations instantiated here are ok if their pattern is 33 inline void use_stuff() { 34 fn<char>(); 35 cls<char>(); 36 (void)var<char>; 37 cls<char*>(); 38 (void)var<char*>; 39 cls<void>::nested_fn_t<char>(); 40 cls<void>::nested_cls_t<char>(); 41 (void)cls<void>::nested_var_t<char>; 42 } 43 } 44