From 7efeddba5c0b9366a7913767364248cf5e2f7ae7 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@dune-project.org> Date: Mon, 8 Nov 2010 15:22:33 +0000 Subject: [PATCH] pretty-print the class name of a type without given object [[Imported from SVN: r6241]] --- dune/common/classname.hh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dune/common/classname.hh b/dune/common/classname.hh index 7099c8a79..f4dafd7db 100644 --- a/dune/common/classname.hh +++ b/dune/common/classname.hh @@ -5,7 +5,7 @@ /** \file * \brief A free function to provide the demangled class name - * of a given object as a string + * of a given object or type as a string */ #ifdef __GNUC__ @@ -26,5 +26,17 @@ namespace Dune { #endif }; + /** \brief Provide the demangled class name of a type T as a string */ + template <class T> + std::string className() + { +#ifdef __GNUC__ + int status; + return abi::__cxa_demangle(typeid(T).name(),0,0,&status); +#else + return typeid(T).name(); +#endif + }; + } #endif // DUNE_CLASSNAME_HH -- GitLab