MRPT  1.9.9
TTypeName_stl.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
14 #include <array>
15 #include <chrono>
16 #include <deque>
17 #include <list>
18 #include <map>
19 #include <set>
20 #include <vector>
21 
22 /** \file This file extends TTypeName.h for STL C++ types. */
23 
24 namespace mrpt::typemeta
25 {
26 /** @name Conversion of type to string at compile time
27 @{ */
28 
30 
31 #define MRPT_DECLARE_TTYPENAME_CONTAINER(_CONTAINER) \
32  template <typename V> \
33  struct TTypeName<_CONTAINER<V>> \
34  { \
35  constexpr static auto get() \
36  { \
37  return literal(#_CONTAINER) + literal("<") + TTypeName<V>::get() + \
38  literal(">"); \
39  } \
40  };
41 
46 
47 // array<T,N>
48 #define MRPT_DECLARE_TTYPENAME_CONTAINER_FIX_SIZE(_CONTAINER) \
49  template <typename V, std::size_t N> \
50  struct TTypeName<_CONTAINER<V, N>> \
51  { \
52  constexpr static auto get() \
53  { \
54  return literal(#_CONTAINER) + literal("<") + TTypeName<V>::get() + \
55  literal(",") + literal(num_to_string<N>::value) + \
56  literal(">"); \
57  } \
58  };
59 
61 
62 #define MRPT_DECLARE_TTYPENAME_CONTAINER_ASSOC(_CONTAINER) \
63  template <typename K, typename V> \
64  struct TTypeName<_CONTAINER<K, V>> \
65  { \
66  constexpr static auto get() \
67  { \
68  return literal(#_CONTAINER) + literal("<") + TTypeName<K>::get() + \
69  literal(",") + TTypeName<V>::get() + literal(">"); \
70  } \
71  };
72 
75 
76 template <typename T1, typename T2>
77 struct TTypeName<std::pair<T1, T2>>
78 {
79  constexpr static auto get()
80  {
81  return literal("std::pair<") + TTypeName<T1>::get() + literal(",") +
82  TTypeName<T2>::get() + literal(">");
83  }
84 };
85 
86 template <typename T>
87 struct TTypeName<std::chrono::time_point<T>>
88 {
89  constexpr static auto get()
90  {
91  // uint64_t for backwards compatibility
92  return literal("uint64_t");
93  }
94 };
95 
96 /** @} */
97 
98 } // namespace mrpt::typemeta
#define MRPT_DECLARE_TTYPENAME_CONTAINER_ASSOC(_CONTAINER)
Definition: TTypeName_stl.h:62
STL namespace.
A template to obtain the type of its argument as a string at compile time.
Definition: TTypeName.h:69
constexpr auto literal(const char(&lit)[N_PLUS_1]) -> string_literal< N_PLUS_1 - 1 >
Definition: static_string.h:46
#define MRPT_DECLARE_TTYPENAME_CONTAINER(_CONTAINER)
Definition: TTypeName_stl.h:31
GLsizei const GLchar ** string
Definition: glext.h:4116
#define MRPT_DECLARE_TTYPENAME_CONTAINER_FIX_SIZE(_CONTAINER)
Definition: TTypeName_stl.h:48
static constexpr auto get()
Definition: TTypeName.h:71
#define MRPT_DECLARE_TTYPENAME(_TYPE)
Definition: TTypeName.h:111



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 45d659fbb Tue Dec 10 18:21:14 2019 +0100 at mar dic 10 18:30:09 CET 2019