MRPT  1.9.9
TTypeName_stl.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 #pragma once
10 
14 #include <chrono>
15 #include <list>
16 #include <vector>
17 #include <deque>
18 #include <set>
19 #include <map>
20 #include <array>
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 }
99 
#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:65
constexpr auto literal(const char(&lit)[N_PLUS_1]) -> string_literal< N_PLUS_1 - 1 >
Definition: static_string.h:43
#define MRPT_DECLARE_TTYPENAME_CONTAINER(_CONTAINER)
Definition: TTypeName_stl.h:31
GLsizei const GLchar ** string
Definition: glext.h:4101
#define MRPT_DECLARE_TTYPENAME_CONTAINER_FIX_SIZE(_CONTAINER)
Definition: TTypeName_stl.h:48
static constexpr auto get()
Definition: TTypeName.h:67
#define MRPT_DECLARE_TTYPENAME(_TYPE)
Definition: TTypeName.h:107



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020