Last active
August 29, 2019 22:29
Revisions
-
psfrolov revised this gist
Aug 29, 2019 . 1 changed file with 37 additions and 37 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,70 +6,70 @@ template<typename T> class Foo { public: std::string Method(); static std::string StaticMethod(); static const std::string StaticData; enum class Enum; struct InnerStruct{ static const std::string StaticData; }; }; template<typename T> std::string Foo<T>::Method() { return "std::string Foo<T>::Method() - primary template."; } template<> std::string Foo<char>::Method() { return "std::string Foo<T>::Method() - " "explicit specialisation for <char>."; } template<typename T> std::string Foo<T>::StaticMethod() { return "std::string Foo<T>::StaticMethod() - primary template."; } template<> std::string Foo<char>::StaticMethod() { return "std::string Foo<char>::StaticMethod() - " "explicit specialisation for <char>."; } template<typename T> const std::string Foo<T>::StaticData{ "std::string Foo<T>::StaticData - primary template." }; template<> const std::string Foo<char>::StaticData{ "std::string Foo<char>::StaticData - " "explicit specialisation for <char>." }; template<typename T> enum class Foo<T>::Enum { Primary = 0 }; template<> enum class Foo<char>::Enum { Specialised = 1 }; template<typename T> const std::string Foo<T>::InnerStruct::StaticData{ "std::string Foo<T>::InnerStruct::StaticData - primary template." }; template<> struct Foo<char>::InnerStruct{ static const std::string StaticData; }; const std::string Foo<char>::InnerStruct::StaticData{ "std::string Foo<char>::InnerStruct::StaticData - " "explicit specialisation for <char>." }; int main() { // Member function. std::cout << Foo<int>().Method() << std::endl; std::cout << Foo<char>().Method() << std::endl; // Static member function. std::cout << Foo<int>::StaticMethod() << std::endl; std::cout << Foo<char>::StaticMethod() << std::endl; // Static data member. std::cout << Foo<int>::StaticData << std::endl; std::cout << Foo<char>::StaticData << std::endl; // Member enumeration. std::cout << static_cast<int>(Foo<int>::Enum::Primary) << std::endl; std::cout << static_cast<int>(Foo<char>::Enum::Specialised) << std::endl; // Member class. std::cout << Foo<int>::InnerStruct::StaticData << std::endl; std::cout << Foo<char>::InnerStruct::StaticData << std::endl; } -
psfrolov revised this gist
Aug 25, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,7 +45,8 @@ template<> enum class Foo<char>::Enum { Specialised = 1 }; template<typename T> const std::string Foo<T>::InnerStruct::StaticData{ "std::string Foo<T>::InnerStruct::StaticData - primary template." }; template<> struct Foo<char>::InnerStruct{ static const std::string StaticData; }; const std::string Foo<char>::InnerStruct::StaticData{ "std::string Foo<char>::InnerStruct::StaticData - " "explicit specialisation for <char>." }; -
Paul revised this gist
Dec 19, 2015 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ template<typename T> std::string Foo<T>::Method() { template<> std::string Foo<char>::Method() { return "std::string Foo<T>::Method() - " "explicit specialisation for <char>."; } template<typename T> std::string Foo<T>::StaticMethod() { @@ -28,27 +28,27 @@ template<typename T> std::string Foo<T>::StaticMethod() { template<> std::string Foo<char>::StaticMethod() { return "std::string Foo<char>::StaticMethod() - " "explicit specialisation for <char>."; } template<typename T> const std::string Foo<T>::StaticData{ "std::string Foo<T>::StaticData - primary template." }; template<> const std::string Foo<char>::StaticData{ "std::string Foo<char>::StaticData - " "explicit specialisation for <char>." }; template<typename T> enum class Foo<T>::Enum { Primary = 0 }; template<> enum class Foo<char>::Enum { Specialised = 1 }; template<typename T> const std::string Foo<T>::InnerStruct::StaticData{ "std::string Foo<T>::InnerStruct::StaticData - primary template." }; template<> struct Foo<char>::InnerStruct{ static const std::string StaticData; }; const std::string Foo<char>::InnerStruct::StaticData{ "std::string Foo<char>::InnerStruct::StaticData - " "explicit specialisation for <char>." }; int main() { @@ -66,7 +66,7 @@ int main() { // Member enumeration. std::cout << static_cast<int>(Foo<int>::Enum::Primary) << std::endl; std::cout << static_cast<int>(Foo<char>::Enum::Specialised) << std::endl; // Member class. std::cout << Foo<int>::InnerStruct::StaticData << std::endl; -
Paul revised this gist
Dec 15, 2015 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,22 +18,25 @@ template<typename T> std::string Foo<T>::Method() { } template<> std::string Foo<char>::Method() { return "std::string Foo<T>::Method() - " "explicit specialization for <char>."; } template<typename T> std::string Foo<T>::StaticMethod() { return "std::string Foo<T>::StaticMethod() - primary template."; } template<> std::string Foo<char>::StaticMethod() { return "std::string Foo<char>::StaticMethod() - " "explicit specialization for <char>."; } template<typename T> const std::string Foo<T>::StaticData{ "std::string Foo<T>::StaticData - primary template." }; template<> const std::string Foo<char>::StaticData{ "std::string Foo<char>::StaticData - " "explicit specialization for <char>." }; template<typename T> enum class Foo<T>::Enum { Primary = 0 }; @@ -44,7 +47,8 @@ template<typename T> const std::string Foo<T>::InnerStruct::StaticData{ template<> struct Foo<char>::InnerStruct{ static const std::string StaticData; }; const std::string Foo<char>::InnerStruct::StaticData{ "std::string Foo<char>::InnerStruct::StaticData - " "explicit specialization for <char>." }; int main() { -
Paul revised this gist
Jan 11, 2015 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,18 +48,23 @@ const std::string Foo<char>::InnerStruct::StaticData{ int main() { // Member function. std::cout << Foo<int>().Method() << std::endl; std::cout << Foo<char>().Method() << std::endl; // Static member function. std::cout << Foo<int>::StaticMethod() << std::endl; std::cout << Foo<char>::StaticMethod() << std::endl; // Static data member. std::cout << Foo<int>::StaticData << std::endl; std::cout << Foo<char>::StaticData << std::endl; // Member enumeration. std::cout << static_cast<int>(Foo<int>::Enum::Primary) << std::endl; std::cout << static_cast<int>(Foo<char>::Enum::Specialized) << std::endl; // Member class. std::cout << Foo<int>::InnerStruct::StaticData << std::endl; std::cout << Foo<char>::InnerStruct::StaticData << std::endl; } -
Paul revised this gist
Jan 11, 2015 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,16 @@ // Tested with Clang 3.4, GCC 4.8.2. #include <iostream> #include <string> template<typename T> class Foo { public: std::string Method(); static std::string StaticMethod(); static const std::string StaticData; enum class Enum; struct InnerStruct{ static const std::string StaticData; }; }; template<typename T> std::string Foo<T>::Method() { @@ -30,6 +35,18 @@ template<typename T> const std::string Foo<T>::StaticData{ template<> const std::string Foo<char>::StaticData{ "std::string Foo<char>::StaticData - explicit specialization for <char>." }; template<typename T> enum class Foo<T>::Enum { Primary = 0 }; template<> enum class Foo<char>::Enum { Specialized = 1 }; template<typename T> const std::string Foo<T>::InnerStruct::StaticData{ "std::string Foo<T>::InnerStruct::StaticData - primary template." }; template<> struct Foo<char>::InnerStruct{ static const std::string StaticData; }; const std::string Foo<char>::InnerStruct::StaticData{ "std::string Foo<char>::InnerStruct::StaticData - explicit specialization for <char>." }; int main() { std::cout << Foo<int>().Method() << std::endl; std::cout << Foo<char>().Method() << std::endl; @@ -39,4 +56,10 @@ int main() { std::cout << Foo<int>::StaticData << std::endl; std::cout << Foo<char>::StaticData << std::endl; std::cout << static_cast<int>(Foo<int>::Enum::Primary) << std::endl; std::cout << static_cast<int>(Foo<char>::Enum::Specialized) << std::endl; std::cout << Foo<int>::InnerStruct::StaticData << std::endl; std::cout << Foo<char>::InnerStruct::StaticData << std::endl; } -
Paul renamed this gist
Jan 11, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Paul revised this gist
Jan 10, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,6 @@ template<typename T> const std::string Foo<T>::StaticData{ template<> const std::string Foo<char>::StaticData{ "std::string Foo<char>::StaticData - explicit specialization for <char>." }; int main() { std::cout << Foo<int>().Method() << std::endl; std::cout << Foo<char>().Method() << std::endl; -
Paul renamed this gist
Jan 10, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Paul renamed this gist
Jan 10, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Paul created this gist
Jan 10, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ #include <iostream> #include <string> template<typename T> class Foo { public: std::string Method(); static std::string StaticMethod(); static const std::string StaticData; }; template<typename T> std::string Foo<T>::Method() { return "std::string Foo<T>::Method() - primary template."; } template<> std::string Foo<char>::Method() { return "std::string Foo<T>::Method() - explicit specialization for <char>."; } template<typename T> std::string Foo<T>::StaticMethod() { return "std::string Foo<T>::StaticMethod() - primary template."; } template<> std::string Foo<char>::StaticMethod() { return "std::string Foo<char>::StaticMethod() - explicit specialization for <char>."; } template<typename T> const std::string Foo<T>::StaticData{ "std::string Foo<T>::StaticData - primary template." }; template<> const std::string Foo<char>::StaticData{ "std::string Foo<char>::StaticData - explicit specialization for <char>." }; int main() { std::cout << Foo<int>().Method() << std::endl; std::cout << Foo<char>().Method() << std::endl; std::cout << Foo<int>::StaticMethod() << std::endl; std::cout << Foo<char>::StaticMethod() << std::endl; std::cout << Foo<int>::StaticData << std::endl; std::cout << Foo<char>::StaticData << std::endl; }