From 4b87b5920c222aa56222a7c1c27ac0b2d5d60d5a Mon Sep 17 00:00:00 2001 From: Neargye Date: Tue, 28 Aug 2018 19:00:59 +0500 Subject: [PATCH] update example --- example/example.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/example/example.cpp b/example/example.cpp index fc9dc45..3d08c76 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -48,10 +48,9 @@ void SomeMethod3() { std::cout << NAMEOF(SomeMethod3) << " no called!" << std::endl; } -template -std::string SomeMethod4() { - std::cout << NAMEOF_TYPE_T(T) << std::endl; - return NAMEOF_FULL(SomeMethod4); +template +std::string SomeMethod4(U value) { + return std::string(NAMEOF(SomeMethod4)).append("<").append(NAMEOF_TYPE_T(T)).append(", ").append(NAMEOF_TYPE_T(U)).append(">(").append(NAMEOF_TYPE_T(U)).append(" value)"); } template @@ -87,6 +86,8 @@ int main() { constexpr auto constexpr_work_fine = NAMEOF(structvar); static_assert("structvar" == constexpr_work_fine, ""); + std::cout << SomeMethod4(structvar) << std::endl; // SomeMethod4(SomeStruct value) + // Enum name. std::cout << NAMEOF(Color::RED) << std::endl; // RED @@ -104,9 +105,9 @@ int main() { std::cout << NAMEOF(&SomeStruct::SomeMethod2) << std::endl; // SomeMethod2 std::cout << NAMEOF(SomeMethod3) << std::endl; // SomeMethod3 - std::cout << NAMEOF(SomeMethod4()) << std::endl; // SomeMethod4 - std::cout << NAMEOF(SomeMethod4) << std::endl; // SomeMethod4 - std::cout << NAMEOF_FULL(SomeMethod4) << std::endl; // SomeMethod4 + std::cout << NAMEOF(SomeMethod4(1.0f)) << std::endl; // SomeMethod4 + std::cout << NAMEOF(SomeMethod4) << std::endl; // SomeMethod4 + std::cout << NAMEOF_FULL(SomeMethod4) << std::endl; // SomeMethod4 std::cout << NAMEOF(&SomeClass::SomeMethod5) << std::endl; // SomeMethod5 @@ -143,7 +144,7 @@ int main() { } /* Remarks */ -#if 1 +#if 0 // This expression does not have a name. std::cout << NAMEOF("Bad case"_string) << std::endl; // '_string' std::cout << NAMEOF(42.0) << std::endl; // '0'