From f7b04afe4d61e46c9265209fa2e2d8b61c8c9d4f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 29 Sep 2021 21:34:23 +0300 Subject: [PATCH] Add documentation for type_name --- doc/core.qbk | 1 + doc/type_name.qbk | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 doc/type_name.qbk diff --git a/doc/core.qbk b/doc/core.qbk index b8db584..9c20459 100644 --- a/doc/core.qbk +++ b/doc/core.qbk @@ -65,5 +65,6 @@ criteria for inclusion is that the utility component be: [include scoped_enum.qbk] [include swap.qbk] [include typeinfo.qbk] +[include type_name.qbk] [include uncaught_exceptions.qbk] [include use_default.qbk] diff --git a/doc/type_name.qbk b/doc/type_name.qbk new file mode 100644 index 0000000..1a29c7e --- /dev/null +++ b/doc/type_name.qbk @@ -0,0 +1,77 @@ +[/ + Copyright 2021 Peter Dimov + Distributed under the Boost Software License, Version 1.0. + https://boost.org/LICENSE_1_0.txt +] + +[section:type_name type_name] + +[simplesect Authors] + +* Peter Dimov + +[endsimplesect] + +[section Header ] + +The header `` defines the function +template `boost::core::type_name()` that returns a string +representation of the name of `T`, suitable for logging or +diagnostic display purposes. + +The result is similar to `boost::core::demangle( typeid(T).name() )`, +but it's made more regular by eliminating some of the platform-specific +differences and extra template parameters of the standard library +container types. + +For example, `type_name< std::map >()` returns +`std::map` and not + +``` + std::map, + std::allocator >, int, std::less, std::allocator > >, std::allocator< + std::pair, + std::allocator > const, int> > > +``` + +or + +``` + class std::map, + class std::allocator >,int,struct std::less,class std::allocator > >,class + std::allocator,class std::allocator > const ,int> > > +``` + +The return values aren't guaranteed to be stable across Boost releases. + +Compilation with `-fno-rtti` is supported, but the returned type names aren't +guaranteed to be particularly useful or unique. + +[section Synopsis] + +`` +namespace boost +{ +namespace core +{ + +template std::string type_name(); + +} // namespace core +} // namespace boost +`` + +[endsect] + +[section template std::string type_name();] + +* *Returns:* A string representation of the name of `T`. + +[endsect] + +[endsect] + +[endsect]