// Copyright Kevlin Henney, 2000-2005. // Copyright Alexander Nasonov, 2006-2010. // Copyright Antony Polukhin, 2011-2018. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // what: lexical_cast custom keyword cast // who: contributed by Kevlin Henney, // enhanced with contributions from Terje Slettebo, // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, // Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, // Cheng Yang, Matthew Bradbury, David W. Birdsall, Pavel Korzh and other Boosters // when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2014 #ifndef BOOST_LEXICAL_CAST_INCLUDED #define BOOST_LEXICAL_CAST_INCLUDED #include #ifdef BOOST_HAS_PRAGMA_ONCE # pragma once #endif #if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) #define BOOST_LCAST_NO_WCHAR_T #endif #include #include #include namespace lslboost { template inline Target lexical_cast(const Source &arg) { Target result = Target(); if (!lslboost::conversion::detail::try_lexical_convert(arg, result)) { lslboost::conversion::detail::throw_bad_cast(); } return result; } template inline Target lexical_cast(const char* chars, std::size_t count) { return ::lslboost::lexical_cast( ::lslboost::iterator_range(chars, chars + count) ); } template inline Target lexical_cast(const unsigned char* chars, std::size_t count) { return ::lslboost::lexical_cast( ::lslboost::iterator_range(chars, chars + count) ); } template inline Target lexical_cast(const signed char* chars, std::size_t count) { return ::lslboost::lexical_cast( ::lslboost::iterator_range(chars, chars + count) ); } #ifndef BOOST_LCAST_NO_WCHAR_T template inline Target lexical_cast(const wchar_t* chars, std::size_t count) { return ::lslboost::lexical_cast( ::lslboost::iterator_range(chars, chars + count) ); } #endif #ifndef BOOST_NO_CXX11_CHAR16_T template inline Target lexical_cast(const char16_t* chars, std::size_t count) { return ::lslboost::lexical_cast( ::lslboost::iterator_range(chars, chars + count) ); } #endif #ifndef BOOST_NO_CXX11_CHAR32_T template inline Target lexical_cast(const char32_t* chars, std::size_t count) { return ::lslboost::lexical_cast( ::lslboost::iterator_range(chars, chars + count) ); } #endif } // namespace lslboost #undef BOOST_LCAST_NO_WCHAR_T #endif // BOOST_LEXICAL_CAST_INCLUDED