]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // boost/chrono/utility/to_string.hpp |
2 | // | |
3 | // Copyright 2011 Vicente J. Botet Escriba | |
4 | // Use, modification and distribution are subject to the Boost Software License, | |
5 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt). | |
7 | ||
8 | #ifndef BOOST_CHRONO_UTILITY_TO_STRING_HPP | |
9 | #define BOOST_CHRONO_UTILITY_TO_STRING_HPP | |
10 | ||
11 | #include <boost/chrono/config.hpp> | |
12 | #include <string> | |
13 | #include <sstream> | |
14 | ||
15 | namespace boost | |
16 | { | |
17 | namespace chrono | |
18 | { | |
19 | template <typename CharT, typename T> | |
20 | std::basic_string<CharT> to_basic_string(T const&v) { | |
21 | std::basic_stringstream<CharT> sstr; | |
22 | sstr << v; | |
23 | return sstr.str(); | |
24 | } | |
25 | ||
26 | template <typename T> | |
27 | std::string to_string(T const&v) { | |
28 | return to_basic_string<char>(v); | |
29 | } | |
30 | #ifndef BOOST_NO_STD_WSTRING | |
31 | template <typename T> | |
32 | std::wstring to_wstring(T const&v) { | |
33 | return to_basic_string<wchar_t>(v); | |
34 | } | |
35 | #endif | |
36 | #if BOOST_CHRONO_HAS_UNICODE_SUPPORT | |
37 | template <typename T> | |
38 | std::basic_string<char16_t> to_u16string(T const&v) { | |
39 | return to_basic_string<char16_t>(v); | |
40 | } | |
41 | template <typename T> | |
42 | std::basic_string<char32_t> to_u32string(T const&v) { | |
43 | return to_basic_string<char32_t>(v); | |
44 | } | |
45 | #endif | |
46 | } // chrono | |
47 | ||
48 | } // boost | |
49 | ||
50 | #endif // header |