Main MRPT website > C++ reference for MRPT 1.9.9
lib_mrpt_typemeta.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 /** \defgroup mrpt_typemeta_grp [mrpt-typemeta]
11 
12 Metaprogramming header-only library to obtain `constexpr` textual string representations of enum types and type names, including smart pointers and complex STL compound types.
13 
14 <small> <a href="index.html#libs">Back to list of all libraries</a> | <a href="modules.html" >See all modules</a> </small>
15 <br>
16 
17 # Library `mrpt-typemeta`
18 <small> [New in MRPT 2.0.0] </small>
19 
20 This library is part of MRPT but has no dependencies, so it can be installed
21 in Debian-based systems with:
22 
23  sudo apt install libmrpt-typemeta-dev
24 
25 ## Example #1: compile-time type/struct/class names to strings
26 Use mrpt::typemeta::TTypeName to extract a `constexpr` string with a compiler-independent
27 representation of arbitrarily-complex types and STL containers.
28 Note that creating objects from a run-time string representation of its type
29 is handled in a different library (\ref mrpt_serialization_grp).
30 
31 See: \ref typemeta_TTypeName/test.cpp
32 \snippet typemeta_TTypeName/test.cpp example typename
33 Output:
34 \include typemeta_TTypeName/console.out
35 
36 ## Example #2: compile-time constexpr strings manipulation
37 See: \ref typemeta_StaticString/test.cpp
38 \snippet typemeta_StaticString/test.cpp example sstring
39 Output:
40 \include typemeta_StaticString/console-sstring.out
41 
42 ## Example #3: compile-time numbers to strings
43 See: \ref typemeta_StaticString/test.cpp
44 \snippet typemeta_StaticString/test.cpp example num2str
45 Output:
46 \include typemeta_StaticString/console-num2str.out
47 
48 ## Example #4: enum values to/from strings
49 See: \ref typemeta_TEnumType/test.cpp
50 \snippet typemeta_TEnumType/test.cpp example
51 Output:
52 \include typemeta_TEnumType/console.out
53 
54 */



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST