1 #ifndef BOOST_MATH_S__HPP
2 #define BOOST_MATH_S__HPP
4 // Copyright (c) 2006 Johan Rade
5 // Copyright (c) 2012 Paul A. Bristow
7 // Distributed under the Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt
9 // or copy at http://www.boost.org/LICENSE_1_0.txt)
11 // The macro S_ lets you write
13 // basic_string<CharType> s = S_("foo");
15 // CharType c = S_('a');
17 // provided that CharType is either char or wchar_t.
18 // Used by tests of output of signed zero and others.
21 # pragma warning(push)
22 # pragma warning(disable : 4512) // conditional expression is constant.
27 //------------------------------------------------------------------------------
29 #define S_(a) make_literal_helper(a, L##a)
31 class char_literal_helper {
33 char_literal_helper(char c, wchar_t wc) : c_(c), wc_(wc) {}
34 operator char() { return c_; }
35 operator wchar_t() { return wc_; }
41 class string_literal_helper {
43 string_literal_helper(const char* s, const wchar_t* ws) : s_(s), ws_(ws) {}
44 operator std::string() { return s_; }
45 operator std::wstring() { return ws_; }
51 inline char_literal_helper make_literal_helper(char c, wchar_t wc)
53 return char_literal_helper(c, wc);
56 inline string_literal_helper make_literal_helper(const char* s, const wchar_t* ws)
58 return string_literal_helper(s, ws);
61 //------------------------------------------------------------------------------
67 #endif // BOOST_MATH_S__HPP