diff --git a/example/example.cpp b/example/example.cpp index eccd05b..1ce0549 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -26,6 +26,7 @@ #include #include #include +#include constexpr long double operator"" _deg(long double deg) { return deg * 3.141592 / 180.0; @@ -36,7 +37,7 @@ std::string operator"" _string(const char* str, std::size_t) { } struct SomeStruct { - int somefield; + int somefield = 0; void SomeMethod1(const int i) { somefield = i; @@ -52,11 +53,13 @@ void SomeMethod3() { } template -void SomeMethod4() {} +T SomeMethod4() { + return T{}; +} struct Long { struct LL { - int field; + int field = 0; }; LL ll; }; @@ -65,9 +68,9 @@ enum class Color { RED, GREEN, BLUE }; SomeStruct somevar; Long othervar; -int intvar; -SomeStruct* ptrvar; -SomeStruct** ptrptrvar; +int intvar = 0; +SomeStruct* ptrvar = &somevar; +SomeStruct** ptrptrvar = &ptrvar; int main() { // constexpr @@ -145,7 +148,8 @@ int main() { std::cout << NAMEOF(std::string()) << std::endl; // 'string()' std::cout << NAMEOF(std::string{}) << std::endl; // "string{}' std::cout << NAMEOF(std::string{"test"}) << std::endl; // 'string{"test"}' - std::cout << NAMEOF(SomeMethod4) << std::endl; // '' + std::cout << NAMEOF(SomeMethod4()) << std::endl; // '()' + std::cout << NAMEOF(std::basic_string) << std::endl; // '' std::cout << NAMEOF(ptrvar[0]) << std::endl; // 'ptrvar[0]' std::cout << NAMEOF(intvar + intvar) << std::endl; // ' intvar' std::cout << NAMEOF(NAMEOF(intvar)) << std::endl; // 'NAMEOF(intvar)' diff --git a/test/test.cpp b/test/test.cpp index 9775a85..8f8c647 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -31,7 +31,7 @@ #include struct SomeStruct { - int somefield; + int somefield = 0; void SomeMethod1(const int i) { somefield = i; @@ -48,7 +48,7 @@ void SomeMethod3() { throw std::exception{}; } struct Long { struct LL { - int field; + int field = 0; }; LL ll; }; @@ -57,9 +57,9 @@ enum class Color { RED, GREEN, BLUE }; SomeStruct somevar; Long othervar; -int intvar; -SomeStruct* ptrvar; -SomeStruct** ptrptrvar; +int intvar = 0; +SomeStruct* ptrvar = &somevar; +SomeStruct** ptrptrvar = &ptrvar; TEST_CASE("constexpr") { SECTION("NAMEOF") {