summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/CppUnit/src/include/cppunit/tools/StringHelper.h')
-rw-r--r--3rdParty/CppUnit/src/include/cppunit/tools/StringHelper.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/3rdParty/CppUnit/src/include/cppunit/tools/StringHelper.h b/3rdParty/CppUnit/src/include/cppunit/tools/StringHelper.h
new file mode 100644
index 0000000..3301045
--- /dev/null
+++ b/3rdParty/CppUnit/src/include/cppunit/tools/StringHelper.h
@@ -0,0 +1,45 @@
1#ifndef CPPUNIT_TOOLS_STRINGHELPER_H
2#define CPPUNIT_TOOLS_STRINGHELPER_H
3
4#include <cppunit/Portability.h>
5#include <cppunit/portability/Stream.h>
6#include <string>
7#include <type_traits>
8
9
10CPPUNIT_NS_BEGIN
11
12
13/*! \brief Methods for converting values to strings. Replaces CPPUNIT_NS::StringTools::toString
14 */
15namespace StringHelper
16{
17
18// work around to handle C++11 enum class correctly. We need an own conversion to std::string
19// as there is no implicit coversion to int for enum class.
20
21template<typename T>
22typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
23{
24 OStringStream ost;
25 ost << x;
26
27 return ost.str();
28}
29
30template<typename T>
31typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
32{
33 OStringStream ost;
34 ost << static_cast<typename std::underlying_type<T>::type>(x);
35
36 return ost.str();
37}
38
39}
40
41
42CPPUNIT_NS_END
43
44#endif // CPPUNIT_TOOLS_STRINGHELPER_H
45