MRPT  1.9.9
format.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 
10 #pragma once
11 
12 #include <mrpt/core/common.h>
13 #include <string>
14 
15 /** This is the global namespace for all Mobile Robot Programming Toolkit (MRPT)
16  * libraries. */
17 namespace mrpt
18 {
19 /** A std::string version of C sprintf.
20  * You can call this to obtain a std::string using printf-like syntax.
21  * \ingroup mrpt_core_grp
22  */
23 std::string format(const char* fmt, ...) MRPT_printf_format_check(1, 2);
24 
25 /** Just like std::to_string(), but with an overloaded version
26  * for std::string arguments.
27  * \ingroup mrpt_core_grp
28  */
29 template <typename T>
30 std::string to_string(T v)
31 {
32  return std::to_string(v);
33 }
34 template <>
35 inline std::string to_string<>(std::string v)
36 {
37  return v;
38 }
39 template <>
40 inline std::string to_string<>(bool v)
41 {
42  return v ? "true" : "false";
43 }
44 template <>
45 inline std::string to_string<>(const char* s)
46 {
47  return std::string(s);
48 }
49 } // namespace mrpt
STL namespace.
GLdouble s
Definition: glext.h:3682
GLsizei const GLchar ** string
Definition: glext.h:4116
const GLdouble * v
Definition: glext.h:3684
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
std::string std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
Definition: format.h:30
std::string to_string(const char *s)
Definition: format.h:45
#define MRPT_printf_format_check(_FMT_, _VARARGS_)
Definition: common.h:158



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019