update boost
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -59,7 +59,7 @@ namespace boost {
|
||||
{
|
||||
// Converts signed/unsigned char to char
|
||||
template < class Char >
|
||||
struct normalize_single_byte_char
|
||||
struct normalize_single_byte_char
|
||||
{
|
||||
typedef Char type;
|
||||
};
|
||||
@@ -79,7 +79,7 @@ namespace boost {
|
||||
|
||||
namespace detail // deduce_character_type_later<T>
|
||||
{
|
||||
// Helper type, meaning that stram character for T must be deduced
|
||||
// Helper type, meaning that stram character for T must be deduced
|
||||
// at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
|
||||
template < class T > struct deduce_character_type_later {};
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace boost {
|
||||
Char,
|
||||
boost::detail::deduce_character_type_later< boost::iterator_range< Char* > >
|
||||
> {};
|
||||
|
||||
|
||||
template < typename Char >
|
||||
struct stream_char_common< boost::iterator_range< const Char* > >: public boost::conditional<
|
||||
boost::detail::is_character< Char >::value,
|
||||
@@ -187,19 +187,19 @@ namespace boost {
|
||||
// Otherwise supplied type T is a character type, that must be normalized
|
||||
// using normalize_single_byte_char<Char>.
|
||||
// Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
|
||||
template < class Char >
|
||||
template < class Char >
|
||||
struct deduce_source_char_impl
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::normalize_single_byte_char< Char >::type type;
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::normalize_single_byte_char< Char >::type type;
|
||||
};
|
||||
|
||||
template < class T >
|
||||
struct deduce_source_char_impl< deduce_character_type_later< T > >
|
||||
|
||||
template < class T >
|
||||
struct deduce_source_char_impl< deduce_character_type_later< T > >
|
||||
{
|
||||
typedef boost::has_left_shift< std::basic_ostream< char >, T > result_t;
|
||||
|
||||
#if defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value),
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value),
|
||||
"Source type is not std::ostream`able and std::wostream`s are not supported by your STL implementation");
|
||||
typedef char type;
|
||||
#else
|
||||
@@ -207,7 +207,7 @@ namespace boost {
|
||||
result_t::value, char, wchar_t
|
||||
>::type type;
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_left_shift< std::basic_ostream< type >, T >::value),
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_left_shift< std::basic_ostream< type >, T >::value),
|
||||
"Source type is neither std::ostream`able nor std::wostream`able");
|
||||
#endif
|
||||
};
|
||||
@@ -220,47 +220,47 @@ namespace boost {
|
||||
// Otherwise supplied type T is a character type, that must be normalized
|
||||
// using normalize_single_byte_char<Char>.
|
||||
// Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>)
|
||||
template < class Char >
|
||||
struct deduce_target_char_impl
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME normalize_single_byte_char< Char >::type type;
|
||||
template < class Char >
|
||||
struct deduce_target_char_impl
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME normalize_single_byte_char< Char >::type type;
|
||||
};
|
||||
|
||||
template < class T >
|
||||
struct deduce_target_char_impl< deduce_character_type_later<T> >
|
||||
{
|
||||
|
||||
template < class T >
|
||||
struct deduce_target_char_impl< deduce_character_type_later<T> >
|
||||
{
|
||||
typedef boost::has_right_shift<std::basic_istream<char>, T > result_t;
|
||||
|
||||
#if defined(BOOST_LCAST_NO_WCHAR_T)
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value),
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value),
|
||||
"Target type is not std::istream`able and std::wistream`s are not supported by your STL implementation");
|
||||
typedef char type;
|
||||
#else
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::conditional<
|
||||
result_t::value, char, wchar_t
|
||||
>::type type;
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value),
|
||||
|
||||
BOOST_STATIC_ASSERT_MSG((result_t::value || boost::has_right_shift<std::basic_istream<wchar_t>, T >::value),
|
||||
"Target type is neither std::istream`able nor std::wistream`able");
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail // deduce_target_char<T> and deduce_source_char<T>
|
||||
{
|
||||
// We deduce stream character types in two stages.
|
||||
//
|
||||
// Stage 1 is common for Target and Source. At Stage 1 we get
|
||||
// Stage 1 is common for Target and Source. At Stage 1 we get
|
||||
// non normalized character type (may contain unsigned/signed char)
|
||||
// or deduce_character_type_later<T> where T is the original type.
|
||||
// Stage 1 is executed by stream_char_common<T>
|
||||
//
|
||||
// At Stage 2 we normalize character types or try to deduce character
|
||||
// type using metafunctions.
|
||||
// Stage 2 is executed by deduce_target_char_impl<T> and
|
||||
// At Stage 2 we normalize character types or try to deduce character
|
||||
// type using metafunctions.
|
||||
// Stage 2 is executed by deduce_target_char_impl<T> and
|
||||
// deduce_source_char_impl<T>
|
||||
//
|
||||
// deduce_target_char<T> and deduce_source_char<T> functions combine
|
||||
// deduce_target_char<T> and deduce_source_char<T> functions combine
|
||||
// both stages
|
||||
|
||||
template < class T >
|
||||
@@ -322,7 +322,7 @@ namespace boost {
|
||||
typedef const T * type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace detail // lcast_src_length
|
||||
{
|
||||
// Return max. length of string representation of Source;
|
||||
@@ -368,7 +368,7 @@ namespace boost {
|
||||
// -1.23456789e-123456
|
||||
// ^ sign
|
||||
// ^ leading digit
|
||||
// ^ decimal point
|
||||
// ^ decimal point
|
||||
// ^^^^^^^^ lcast_precision<Source>::value
|
||||
// ^ "e"
|
||||
// ^ exponent sign
|
||||
@@ -401,11 +401,11 @@ namespace boost {
|
||||
struct lexical_cast_stream_traits {
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::array_to_pointer_decay<Source>::type src;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::remove_cv<src>::type no_cv_src;
|
||||
|
||||
|
||||
typedef boost::detail::deduce_source_char<no_cv_src> deduce_src_char_metafunc;
|
||||
typedef BOOST_DEDUCED_TYPENAME deduce_src_char_metafunc::type src_char_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::deduce_target_char<Target>::type target_char_t;
|
||||
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::detail::widest_char<
|
||||
target_char_t, src_char_t
|
||||
>::type char_type;
|
||||
@@ -426,33 +426,33 @@ namespace boost {
|
||||
BOOST_DEDUCED_TYPENAME boost::detail::extract_char_traits<char_type, Target>,
|
||||
BOOST_DEDUCED_TYPENAME boost::detail::extract_char_traits<char_type, no_cv_src>
|
||||
>::type::trait_t traits;
|
||||
|
||||
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
boost::is_same<char, src_char_t>::value && // source is not a wide character based type
|
||||
(sizeof(char) != sizeof(target_char_t)) && // target type is based on wide character
|
||||
(!(boost::detail::is_character<no_cv_src>::value))
|
||||
> is_string_widening_required_t;
|
||||
> is_string_widening_required_t;
|
||||
|
||||
typedef boost::integral_constant<
|
||||
bool,
|
||||
!(boost::is_integral<no_cv_src>::value ||
|
||||
!(boost::is_integral<no_cv_src>::value ||
|
||||
boost::detail::is_character<
|
||||
BOOST_DEDUCED_TYPENAME deduce_src_char_metafunc::stage1_type // if we did not get character type at stage1
|
||||
>::value // then we have no optimization for that type
|
||||
)
|
||||
> is_source_input_not_optimized_t;
|
||||
|
||||
)
|
||||
> is_source_input_not_optimized_t;
|
||||
|
||||
// If we have an optimized conversion for
|
||||
// Source, we do not need to construct stringbuf.
|
||||
BOOST_STATIC_CONSTANT(bool, requires_stringbuf =
|
||||
(is_string_widening_required_t::value || is_source_input_not_optimized_t::value)
|
||||
BOOST_STATIC_CONSTANT(bool, requires_stringbuf =
|
||||
(is_string_widening_required_t::value || is_source_input_not_optimized_t::value)
|
||||
);
|
||||
|
||||
|
||||
typedef boost::detail::lcast_src_length<no_cv_src> len_t;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename Target, typename Source>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -36,8 +36,9 @@
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/lcast_precision.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/core/snprintf.hpp>
|
||||
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
# include <locale>
|
||||
@@ -76,7 +77,7 @@
|
||||
#include <boost/container/container_fwd.hpp>
|
||||
#include <boost/integer.hpp>
|
||||
#include <boost/detail/basic_pointerbuf.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
# include <cwchar>
|
||||
#endif
|
||||
@@ -154,7 +155,7 @@ namespace boost {
|
||||
CharT buffer[CharacterBufferSize];
|
||||
|
||||
// After the `operator <<` finishes, `[start, finish)` is
|
||||
// the range to output by `operator >>`
|
||||
// the range to output by `operator >>`
|
||||
const CharT* start;
|
||||
const CharT* finish;
|
||||
|
||||
@@ -165,7 +166,7 @@ namespace boost {
|
||||
, start(buffer)
|
||||
, finish(buffer + CharacterBufferSize)
|
||||
{}
|
||||
|
||||
|
||||
const CharT* cbegin() const BOOST_NOEXCEPT {
|
||||
return start;
|
||||
}
|
||||
@@ -279,11 +280,7 @@ namespace boost {
|
||||
using namespace std;
|
||||
const double val_as_double = val;
|
||||
finish = start +
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
sprintf_s(begin, CharacterBufferSize,
|
||||
#else
|
||||
sprintf(begin,
|
||||
#endif
|
||||
boost::core::snprintf(begin, CharacterBufferSize,
|
||||
"%.*g", static_cast<int>(boost::detail::lcast_get_precision<float>()), val_as_double);
|
||||
return finish > start;
|
||||
}
|
||||
@@ -291,11 +288,7 @@ namespace boost {
|
||||
bool shl_real_type(double val, char* begin) {
|
||||
using namespace std;
|
||||
finish = start +
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
sprintf_s(begin, CharacterBufferSize,
|
||||
#else
|
||||
sprintf(begin,
|
||||
#endif
|
||||
boost::core::snprintf(begin, CharacterBufferSize,
|
||||
"%.*g", static_cast<int>(boost::detail::lcast_get_precision<double>()), val);
|
||||
return finish > start;
|
||||
}
|
||||
@@ -304,11 +297,7 @@ namespace boost {
|
||||
bool shl_real_type(long double val, char* begin) {
|
||||
using namespace std;
|
||||
finish = start +
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
sprintf_s(begin, CharacterBufferSize,
|
||||
#else
|
||||
sprintf(begin,
|
||||
#endif
|
||||
boost::core::snprintf(begin, CharacterBufferSize,
|
||||
"%.*Lg", static_cast<int>(boost::detail::lcast_get_precision<long double>()), val );
|
||||
return finish > start;
|
||||
}
|
||||
@@ -375,15 +364,15 @@ namespace boost {
|
||||
}
|
||||
|
||||
template <class C>
|
||||
BOOST_DEDUCED_TYPENAME boost::disable_if<boost::is_const<C>, bool>::type
|
||||
BOOST_DEDUCED_TYPENAME boost::disable_if<boost::is_const<C>, bool>::type
|
||||
operator<<(const iterator_range<C*>& rng) BOOST_NOEXCEPT {
|
||||
return (*this) << iterator_range<const C*>(rng.begin(), rng.end());
|
||||
}
|
||||
|
||||
|
||||
bool operator<<(const iterator_range<const CharT*>& rng) BOOST_NOEXCEPT {
|
||||
start = rng.begin();
|
||||
finish = rng.end();
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator<<(const iterator_range<const signed char*>& rng) BOOST_NOEXCEPT {
|
||||
@@ -454,43 +443,43 @@ namespace boost {
|
||||
return shl_real(static_cast<double>(val));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Adding constness to characters. Constness does not change layout
|
||||
template <class C, std::size_t N>
|
||||
BOOST_DEDUCED_TYPENAME boost::disable_if<boost::is_const<C>, bool>::type
|
||||
operator<<(boost::array<C, N> const& input) BOOST_NOEXCEPT {
|
||||
operator<<(boost::array<C, N> const& input) BOOST_NOEXCEPT {
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(sizeof(boost::array<const C, N>) == sizeof(boost::array<C, N>)),
|
||||
"boost::array<C, N> and boost::array<const C, N> must have exactly the same layout."
|
||||
);
|
||||
return ((*this) << reinterpret_cast<boost::array<const C, N> const& >(input));
|
||||
return ((*this) << reinterpret_cast<boost::array<const C, N> const& >(input));
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
bool operator<<(boost::array<const CharT, N> const& input) BOOST_NOEXCEPT {
|
||||
bool operator<<(boost::array<const CharT, N> const& input) BOOST_NOEXCEPT {
|
||||
return shl_char_array_limited(input.data(), N);
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
bool operator<<(boost::array<const unsigned char, N> const& input) BOOST_NOEXCEPT {
|
||||
return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input));
|
||||
bool operator<<(boost::array<const unsigned char, N> const& input) BOOST_NOEXCEPT {
|
||||
return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input));
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
bool operator<<(boost::array<const signed char, N> const& input) BOOST_NOEXCEPT {
|
||||
return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input));
|
||||
bool operator<<(boost::array<const signed char, N> const& input) BOOST_NOEXCEPT {
|
||||
return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input));
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
||||
// Making a Boost.Array from std::array
|
||||
template <class C, std::size_t N>
|
||||
bool operator<<(std::array<C, N> const& input) BOOST_NOEXCEPT {
|
||||
bool operator<<(std::array<C, N> const& input) BOOST_NOEXCEPT {
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(sizeof(std::array<C, N>) == sizeof(boost::array<C, N>)),
|
||||
"std::array and boost::array must have exactly the same layout. "
|
||||
"Bug in implementation of std::array or boost::array."
|
||||
);
|
||||
return ((*this) << reinterpret_cast<boost::array<C, N> const& >(input));
|
||||
return ((*this) << reinterpret_cast<boost::array<C, N> const& >(input));
|
||||
}
|
||||
#endif
|
||||
template <class InStreamable>
|
||||
@@ -500,7 +489,7 @@ namespace boost {
|
||||
|
||||
template <class CharT, class Traits>
|
||||
class lexical_ostream_limited_src: boost::noncopyable {
|
||||
//`[start, finish)` is the range to output by `operator >>`
|
||||
//`[start, finish)` is the range to output by `operator >>`
|
||||
const CharT* start;
|
||||
const CharT* const finish;
|
||||
|
||||
@@ -580,7 +569,7 @@ namespace boost {
|
||||
#else
|
||||
typedef BOOST_DEDUCED_TYPENAME out_stream_helper_trait<CharT, Traits>::buffer_t buffer_t;
|
||||
buffer_t buf;
|
||||
// Usually `istream` and `basic_istream` do not modify
|
||||
// Usually `istream` and `basic_istream` do not modify
|
||||
// content of buffer; `buffer_t` assures that this is true
|
||||
buf.setbuf(const_cast<CharT*>(start), static_cast<typename buffer_t::streamsize>(finish - start));
|
||||
#if defined(BOOST_NO_STD_LOCALE)
|
||||
@@ -597,7 +586,7 @@ namespace boost {
|
||||
stream.unsetf(std::ios::skipws);
|
||||
lcast_set_precision(stream, static_cast<InputStreamable*>(0));
|
||||
|
||||
return (stream >> output)
|
||||
return (stream >> output)
|
||||
&& (stream.get() == Traits::eof());
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
@@ -625,7 +614,7 @@ namespace boost {
|
||||
bool shr_std_array(ArrayT& output) BOOST_NOEXCEPT {
|
||||
using namespace std;
|
||||
const std::size_t size = static_cast<std::size_t>(finish - start);
|
||||
if (size > N - 1) { // `-1` because we need to store \0 at the end
|
||||
if (size > N - 1) { // `-1` because we need to store \0 at the end
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -668,33 +657,33 @@ namespace boost {
|
||||
bool operator>>(char32_t& output) { return shr_xchar(output); }
|
||||
#endif
|
||||
template<class Alloc>
|
||||
bool operator>>(std::basic_string<CharT,Traits,Alloc>& str) {
|
||||
str.assign(start, finish); return true;
|
||||
bool operator>>(std::basic_string<CharT,Traits,Alloc>& str) {
|
||||
str.assign(start, finish); return true;
|
||||
}
|
||||
|
||||
template<class Alloc>
|
||||
bool operator>>(boost::container::basic_string<CharT,Traits,Alloc>& str) {
|
||||
str.assign(start, finish); return true;
|
||||
bool operator>>(boost::container::basic_string<CharT,Traits,Alloc>& str) {
|
||||
str.assign(start, finish); return true;
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
bool operator>>(boost::array<CharT, N>& output) BOOST_NOEXCEPT {
|
||||
return shr_std_array<N>(output);
|
||||
bool operator>>(boost::array<CharT, N>& output) BOOST_NOEXCEPT {
|
||||
return shr_std_array<N>(output);
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
bool operator>>(boost::array<unsigned char, N>& output) BOOST_NOEXCEPT {
|
||||
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
|
||||
bool operator>>(boost::array<unsigned char, N>& output) BOOST_NOEXCEPT {
|
||||
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
bool operator>>(boost::array<signed char, N>& output) BOOST_NOEXCEPT {
|
||||
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
|
||||
bool operator>>(boost::array<signed char, N>& output) BOOST_NOEXCEPT {
|
||||
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
||||
template <class C, std::size_t N>
|
||||
bool operator>>(std::array<C, N>& output) BOOST_NOEXCEPT {
|
||||
bool operator>>(std::array<C, N>& output) BOOST_NOEXCEPT {
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(sizeof(std::array<C, N>) == sizeof(boost::array<C, N>)),
|
||||
"std::array<C, N> and boost::array<C, N> must have exactly the same layout."
|
||||
@@ -773,8 +762,8 @@ namespace boost {
|
||||
// Generic istream-based algorithm.
|
||||
// lcast_streambuf_for_target<InputStreamable>::value is true.
|
||||
template <typename InputStreamable>
|
||||
bool operator>>(InputStreamable& output) {
|
||||
return shr_using_base_class(output);
|
||||
bool operator>>(InputStreamable& output) {
|
||||
return shr_using_base_class(output);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/type_traits/is_float.hpp>
|
||||
#include <boost/type_traits/remove_volatile.hpp>
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
@@ -98,7 +99,10 @@ inline bool noexcept_numeric_convert(const Source& arg, Target& result) BOOST_NO
|
||||
>::type converter_t;
|
||||
|
||||
bool res = nothrow_overflow_handler()(converter_t::out_of_range(arg));
|
||||
result = converter_t::low_level_convert(converter_t::nearbyint(arg, res));
|
||||
if (res) {
|
||||
result = converter_t::low_level_convert(converter_t::nearbyint(arg, res));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -152,14 +156,16 @@ struct lexical_cast_dynamic_num_ignoring_minus
|
||||
template <typename Target, typename Source>
|
||||
struct dynamic_num_converter_impl
|
||||
{
|
||||
static inline bool try_convert(const Source &arg, Target& result) BOOST_NOEXCEPT {
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::remove_volatile<Source>::type source_type;
|
||||
|
||||
static inline bool try_convert(source_type arg, Target& result) BOOST_NOEXCEPT {
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::conditional<
|
||||
boost::is_unsigned<Target>::value &&
|
||||
(boost::is_signed<Source>::value || boost::is_float<Source>::value) &&
|
||||
!(boost::is_same<Source, bool>::value) &&
|
||||
(boost::is_signed<source_type>::value || boost::is_float<source_type>::value) &&
|
||||
!(boost::is_same<source_type, bool>::value) &&
|
||||
!(boost::is_same<Target, bool>::value),
|
||||
lexical_cast_dynamic_num_ignoring_minus<Target, Source>,
|
||||
lexical_cast_dynamic_num_not_ignoring_minus<Target, Source>
|
||||
lexical_cast_dynamic_num_ignoring_minus<Target, source_type>,
|
||||
lexical_cast_dynamic_num_not_ignoring_minus<Target, source_type>
|
||||
>::type caster_type;
|
||||
|
||||
return caster_type::try_convert(arg, result);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -27,12 +27,11 @@
|
||||
#define BOOST_LCAST_NO_WCHAR_T
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/math/special_functions/sign.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/core/cmath.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
|
||||
@@ -55,7 +54,6 @@ namespace boost {
|
||||
, const CharT* lc_INFINITY, const CharT* lc_infinity
|
||||
, const CharT opening_brace, const CharT closing_brace) BOOST_NOEXCEPT
|
||||
{
|
||||
using namespace std;
|
||||
if (begin == end) return false;
|
||||
const CharT minus = lcast_char_constants<CharT>::minus;
|
||||
const CharT plus = lcast_char_constants<CharT>::plus;
|
||||
@@ -72,14 +70,14 @@ namespace boost {
|
||||
begin += 3;
|
||||
if (end != begin) {
|
||||
/* It is 'nan(...)' or some bad input*/
|
||||
|
||||
|
||||
if (end - begin < 2) return false; // bad input
|
||||
-- end;
|
||||
if (*begin != opening_brace || *end != closing_brace) return false; // bad input
|
||||
}
|
||||
|
||||
if( !has_minus ) value = std::numeric_limits<T>::quiet_NaN();
|
||||
else value = (boost::math::changesign) (std::numeric_limits<T>::quiet_NaN());
|
||||
else value = boost::core::copysign(std::numeric_limits<T>::quiet_NaN(), static_cast<T>(-1));
|
||||
return true;
|
||||
} else if (
|
||||
( /* 'INF' or 'inf' */
|
||||
@@ -94,7 +92,7 @@ namespace boost {
|
||||
)
|
||||
{
|
||||
if( !has_minus ) value = std::numeric_limits<T>::infinity();
|
||||
else value = (boost::math::changesign) (std::numeric_limits<T>::infinity());
|
||||
else value = -std::numeric_limits<T>::infinity();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -106,24 +104,23 @@ namespace boost {
|
||||
, const CharT* lc_nan
|
||||
, const CharT* lc_infinity) BOOST_NOEXCEPT
|
||||
{
|
||||
using namespace std;
|
||||
const CharT minus = lcast_char_constants<CharT>::minus;
|
||||
if ((boost::math::isnan)(value)) {
|
||||
if ((boost::math::signbit)(value)) {
|
||||
if (boost::core::isnan(value)) {
|
||||
if (boost::core::signbit(value)) {
|
||||
*begin = minus;
|
||||
++ begin;
|
||||
}
|
||||
|
||||
memcpy(begin, lc_nan, 3 * sizeof(CharT));
|
||||
std::memcpy(begin, lc_nan, 3 * sizeof(CharT));
|
||||
end = begin + 3;
|
||||
return true;
|
||||
} else if ((boost::math::isinf)(value)) {
|
||||
if ((boost::math::signbit)(value)) {
|
||||
} else if (boost::core::isinf(value)) {
|
||||
if (boost::core::signbit(value)) {
|
||||
*begin = minus;
|
||||
++ begin;
|
||||
}
|
||||
|
||||
memcpy(begin, lc_infinity, 3 * sizeof(CharT));
|
||||
std::memcpy(begin, lc_infinity, 3 * sizeof(CharT));
|
||||
end = begin + 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -35,8 +35,8 @@ namespace boost {
|
||||
struct is_character
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::integral_constant<
|
||||
bool,
|
||||
boost::is_same< T, char >::value ||
|
||||
bool,
|
||||
boost::is_same< T, char >::value ||
|
||||
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
|
||||
boost::is_same< T, wchar_t >::value ||
|
||||
#endif
|
||||
@@ -46,8 +46,8 @@ namespace boost {
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
boost::is_same< T, char32_t >::value ||
|
||||
#endif
|
||||
boost::is_same< T, unsigned char >::value ||
|
||||
boost::is_same< T, signed char >::value
|
||||
boost::is_same< T, unsigned char >::value ||
|
||||
boost::is_same< T, signed char >::value
|
||||
> type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value = (type::value) );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,7 +23,7 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
namespace boost
|
||||
{
|
||||
namespace detail // '0', '-', '+', 'e', 'E' and '.' constants
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -50,9 +50,9 @@
|
||||
#include <boost/lexical_cast/detail/lcast_char_constants.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/core/noncopyable.hpp>
|
||||
|
||||
namespace boost
|
||||
namespace boost
|
||||
{
|
||||
namespace detail // lcast_to_unsigned
|
||||
{
|
||||
@@ -60,8 +60,8 @@ namespace boost
|
||||
inline
|
||||
BOOST_DEDUCED_TYPENAME boost::make_unsigned<T>::type lcast_to_unsigned(const T value) BOOST_NOEXCEPT {
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::make_unsigned<T>::type result_type;
|
||||
return value < 0
|
||||
? static_cast<result_type>(0u - static_cast<result_type>(value))
|
||||
return value < 0
|
||||
? static_cast<result_type>(0u - static_cast<result_type>(value))
|
||||
: static_cast<result_type>(value);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace boost
|
||||
int_type const m_zero;
|
||||
|
||||
public:
|
||||
lcast_put_unsigned(const T n_param, CharT* finish) BOOST_NOEXCEPT
|
||||
lcast_put_unsigned(const T n_param, CharT* finish) BOOST_NOEXCEPT
|
||||
: m_value(n_param), m_finish(finish)
|
||||
, m_czero(lcast_char_constants<CharT>::zero), m_zero(Traits::to_int_type(m_czero))
|
||||
{
|
||||
@@ -162,7 +162,7 @@ namespace boost
|
||||
T& m_value;
|
||||
const CharT* const m_begin;
|
||||
const CharT* m_end;
|
||||
|
||||
|
||||
public:
|
||||
lcast_ret_unsigned(T& value, const CharT* const begin, const CharT* end) BOOST_NOEXCEPT
|
||||
: m_multiplier_overflowed(false), m_multiplier(1), m_value(value), m_begin(begin), m_end(end)
|
||||
@@ -250,7 +250,7 @@ namespace boost
|
||||
}
|
||||
|
||||
private:
|
||||
// Iteration that does not care about grouping/separators and assumes that all
|
||||
// Iteration that does not care about grouping/separators and assumes that all
|
||||
// input characters are digits
|
||||
inline bool main_convert_iteration() BOOST_NOEXCEPT {
|
||||
CharT const czero = lcast_char_constants<CharT>::zero;
|
||||
@@ -265,7 +265,7 @@ namespace boost
|
||||
// We must correctly handle situations like `000000000000000000000000000001`.
|
||||
// So we take care of overflow only if `dig_value` is not '0'.
|
||||
if (*m_end < czero || *m_end >= czero + 10 // checking for correct digit
|
||||
|| (dig_value && ( // checking for overflow of ...
|
||||
|| (dig_value && ( // checking for overflow of ...
|
||||
m_multiplier_overflowed // ... multiplier
|
||||
|| static_cast<T>(maxv / dig_value) < m_multiplier // ... subvalue
|
||||
|| static_cast<T>(maxv - new_sub_value) < m_value // ... whole expression
|
||||
@@ -273,7 +273,7 @@ namespace boost
|
||||
) return false;
|
||||
|
||||
m_value = static_cast<T>(m_value + new_sub_value);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace boost
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright Kevlin Henney, 2000-2005.
|
||||
// Copyright Alexander Nasonov, 2006-2010.
|
||||
// Copyright Antony Polukhin, 2011-2019.
|
||||
// Copyright Antony Polukhin, 2011-2023.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
Reference in New Issue
Block a user