X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=boost%2Fboost%2Flexical_cast.hpp;h=926b95e43034febdf49f2258f647b962202f5553;hb=b01a9dc187d9cd396a57463ad27511379dcdc9cd;hp=135ef0789585b5b1663815c8211641001a3df260;hpb=0c863a4ec15e40f29ec35b398ac0bd066b433c69;p=lyx.git diff --git a/boost/boost/lexical_cast.hpp b/boost/boost/lexical_cast.hpp index 135ef07895..926b95e430 100644 --- a/boost/boost/lexical_cast.hpp +++ b/boost/boost/lexical_cast.hpp @@ -12,8 +12,9 @@ // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, // and other Boosters -// when: November 2000, March 2003 +// when: November 2000, March 2003, June 2005 +#include #include #include #include @@ -29,8 +30,7 @@ #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) + defined(BOOST_NO_STD_LOCALE) #define DISABLE_WIDE_CHAR_SUPPORT #endif @@ -45,9 +45,9 @@ namespace boost { } bad_lexical_cast( - const std::type_info &s, - const std::type_info &t) : - source(&s), target(&t) + const std::type_info &source_type, + const std::type_info &target_type) : + source(&source_type), target(&target_type) { } const std::type_info &source_type() const @@ -80,11 +80,13 @@ namespace boost }; #ifndef DISABLE_WIDE_CHAR_SUPPORT +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> struct stream_char { typedef wchar_t type; }; +#endif template<> struct stream_char @@ -123,6 +125,11 @@ namespace boost template class lexical_stream { + private: + typedef typename widest_char< + typename stream_char::type, + typename stream_char::type>::type char_type; + public: lexical_stream() { @@ -148,7 +155,16 @@ namespace boost { return !is_pointer::value && stream >> output && - (stream >> std::ws).eof(); + stream.get() == +#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) +// GCC 2.9x lacks std::char_traits<>::eof(). +// We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 +// configurations, which do provide std::char_traits<>::eof(). + + EOF; +#else + std::char_traits::eof(); +#endif } bool operator>>(std::string &output) { @@ -166,10 +182,6 @@ namespace boost } #endif private: - typedef typename widest_char< - typename stream_char::type, - typename stream_char::type>::type char_type; - #if defined(BOOST_NO_STRINGSTREAM) std::strstream stream; #elif defined(BOOST_NO_STD_LOCALE) @@ -180,6 +192,42 @@ namespace boost }; } + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // call-by-const reference version + + namespace detail + { + template + struct array_to_pointer_decay + { + typedef T type; + }; + + template + struct array_to_pointer_decay + { + typedef const T * type; + }; + } + + template + Target lexical_cast(const Source &arg) + { + typedef typename detail::array_to_pointer_decay::type NewSource; + + detail::lexical_stream interpreter; + Target result; + + if(!(interpreter << arg && interpreter >> result)) + throw_exception(bad_lexical_cast(typeid(NewSource), typeid(Target))); + return result; + } + + #else + + // call-by-value fallback version (deprecated) + template Target lexical_cast(Source arg) { @@ -187,19 +235,18 @@ namespace boost Target result; if(!(interpreter << arg && interpreter >> result)) - throw_exception(bad_lexical_cast(typeid(Target), typeid(Source))); + throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return result; } + + #endif } -// Copyright Kevlin Henney, 2000-2003. All rights reserved. +// Copyright Kevlin Henney, 2000-2005. All rights reserved. // -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives. -// -// This software is provided "as is" without express or implied warranty. +// 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) #undef DISABLE_WIDE_CHAR_SUPPORT #endif -