1#ifndef BOOST_MATH_S__HPP 2#define BOOST_MATH_S__HPP 3 4// Copyright (c) 2006 Johan Rade 5// Copyright (c) 2012 Paul A. Bristow 6 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) 10 11// The macro S_ lets you write 12// 13// basic_string<CharType> s = S_("foo"); 14// and 15// CharType c = S_('a'); 16// 17// provided that CharType is either char or wchar_t. 18// Used by tests of output of signed zero and others. 19 20#ifdef _MSC_VER 21# pragma warning(push) 22# pragma warning(disable : 4512) // conditional expression is constant. 23#endif 24 25#include <string> 26 27//------------------------------------------------------------------------------ 28 29#define S_(a) make_literal_helper(a, L##a) 30 31class char_literal_helper { 32public: 33 char_literal_helper(char c, wchar_t wc) : c_(c), wc_(wc) {} 34 operator char() { return c_; } 35 operator wchar_t() { return wc_; } 36private: 37 const char c_; 38 const wchar_t wc_; 39}; 40 41class string_literal_helper { 42public: 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_; } 46private: 47 const char* s_; 48 const wchar_t* ws_; 49}; 50 51inline char_literal_helper make_literal_helper(char c, wchar_t wc) 52{ 53 return char_literal_helper(c, wc); 54} 55 56inline string_literal_helper make_literal_helper(const char* s, const wchar_t* ws) 57{ 58 return string_literal_helper(s, ws); 59} 60 61//------------------------------------------------------------------------------ 62 63#ifdef _MSC_VER 64# pragma warning(pop) 65#endif 66 67#endif // BOOST_MATH_S__HPP 68 69