Main MRPT website > C++ reference for MRPT 1.9.9
num_to_string.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 
11 #include <cstddef> //size_t
12 
13 namespace mrpt
14 {
15 namespace typemeta
16 {
17 namespace detail
18 {
19 template <unsigned... digits>
20 struct to_chars
21 {
22  static const char value[sizeof...(digits) + 1];
23 };
24 
25 template <unsigned... digits>
26 constexpr char to_chars<digits...>::value[sizeof...(digits) + 1] = {
27  ('0' + digits)..., 0};
28 
29 template <unsigned rem, unsigned... digits>
30 struct explode : explode<rem / 10, rem % 10, digits...>
31 {
32 };
33 
34 template <unsigned... digits>
35 struct explode<0, digits...> : to_chars<digits...>
36 {
37 };
38 }
39 
40 /** constexpr string representation of a number.
41  * Use: `num_to_string<NUMBER>::value`.
42  * \note Credits: https://stackoverflow.com/a/24000041/1631514 */
43 template <unsigned num>
45 {
46 };
47 }
48 }
mrpt::typemeta::detail::explode
Definition: num_to_string.h:30
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::typemeta::num_to_string
constexpr string representation of a number.
Definition: num_to_string.h:44
value
GLsizei const GLfloat * value
Definition: glext.h:4117
mrpt::typemeta::detail::to_chars
Definition: num_to_string.h:20



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