MRPT  1.9.9
format.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 #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:3676
GLsizei const GLchar ** string
Definition: glext.h:4101
const GLdouble * v
Definition: glext.h:3678
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020