Run Code | API | Code Wall | Misc | Feedback | Login | Theme | Privacy | Patreon |
C++ CPP Template Metaprogramming - template specializationEXPERIMENT 1 - Check whether type is float pointer -------------------------------------------- is float point type<int> ? = false is float point type<char> ? = false is float point type<float> ? = true is float point type<double> ? = true EXPERIMENT 2 - Type introspection -------------------------------------------- type = int type = char type = float type = const char* type = std::string EXPERIMENT 3 - Templates with integers as arguments -------------------------------------------- getNumberName<0>() = zero getNumberName<1>() = one getNumberName<2>() = two getNumberName<10>() = I down't known getNumberName<14>() = I down't known EXPERIMENT 4 - Templates with bool as arguments -------------------------------------------- boolTemplate<false>::getName>() = false boolTemplate<true>::getName>() = true Check whether types are equal type_equal<int, char>::get() = false type_equal<char, double>::get() = false type_equal<double, double>::get() = true type_equal<int, int>::get() = true [1] Types are not equal [2] Types are equal |
λ
.NET NoSQL database for rapid development
|