Merge from trunk

* Fixes #7799 (optimizations with std::array were not used)
* Fixes #7831 (documentation update)

[SVN r82224]
This commit is contained in:
Antony Polukhin
2012-12-27 18:54:28 +00:00
parent dbda7689e0
commit 16890bf041
4 changed files with 58 additions and 45 deletions

View File

@@ -94,8 +94,12 @@ Library features defined in [@boost:boost/lexical_cast.hpp boost/lexical_cast.hp
namespace boost
{
class bad_lexical_cast;
template<typename Target, typename Source>
Target lexical_cast(const Source& arg);
template <typename Target>
Target lexical_cast(const AnyCharacterType* chars, std::size_t count);
}
``

View File

@@ -151,7 +151,7 @@ namespace boost
#include <cmath>
#include <istream>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
#include <array>
#endif
@@ -294,7 +294,7 @@ namespace boost {
boost::detail::deduce_character_type_later< boost::array< const Char, N > >
> {};
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
template < typename Char, std::size_t N >
struct stream_char_common< std::array<Char, N > >: public boost::mpl::if_c<
boost::detail::is_char_or_wchar< Char >::value,
@@ -308,7 +308,7 @@ namespace boost {
Char,
boost::detail::deduce_character_type_later< std::array< const Char, N > >
> {};
#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#endif
#if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
template <>
@@ -1768,10 +1768,13 @@ namespace boost {
bool operator<<(boost::array<const signed char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
template <std::size_t N>
bool operator<<(std::array<CharT, N> const& input) BOOST_NOEXCEPT
{ return shl_char_array_limited(input.begin(), N); }
{
if (input.size()) return shl_char_array_limited(&input[0], N);
else return true;
}
template <std::size_t N>
bool operator<<(std::array<unsigned char, N> const& input) BOOST_NOEXCEPT
@@ -1783,7 +1786,10 @@ namespace boost {
template <std::size_t N>
bool operator<<(std::array<const CharT, N> const& input) BOOST_NOEXCEPT
{ return shl_char_array_limited(input.begin(), N); }
{
if (input.size()) return shl_char_array_limited(&input[0], N);
else return true;
}
template <std::size_t N>
bool operator<<(std::array<const unsigned char, N> const& input) BOOST_NOEXCEPT
@@ -1792,7 +1798,7 @@ namespace boost {
template <std::size_t N>
bool operator<<(std::array<const signed char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#endif
template <class InStreamable>
bool operator<<(const InStreamable& input) { return shl_input_streamable(input); }
@@ -1984,8 +1990,8 @@ namespace boost {
return false;
}
memcpy(output.begin(), start, size * sizeof(CharT));
*(output.begin() + size) = Traits::to_char_type(0);
memcpy(&output[0], start, size * sizeof(CharT));
output[size] = Traits::to_char_type(0);
return true;
}
@@ -2009,7 +2015,7 @@ namespace boost {
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
}
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
template <std::size_t N>
bool operator>>(std::array<CharT, N>& output) BOOST_NOEXCEPT
{
@@ -2023,11 +2029,11 @@ namespace boost {
}
template <std::size_t N>
bool operator>>(std::array<signed char, N>& in)
bool operator>>(std::array<signed char, N>& output)
{
return ((*this) >> reinterpret_cast<std::array<char, N>& >(output));
}
#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#endif
/*

View File

@@ -50,25 +50,25 @@ static void testing_template_array_output_on_spec_value(T val)
{
arr_type res1 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res1.begin(), ethalon);
BOOST_CHECK_EQUAL(&res1[0], ethalon);
const arr_type res2 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res2.begin(), ethalon);
BOOST_CHECK_EQUAL(&res2[0], ethalon);
BOOST_CHECK_THROW(lexical_cast<short_arr_type>(val), boost::bad_lexical_cast);
}
{
uarr_type res1 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(&res1[0]), ethalon);
const uarr_type res2 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(&res2[0]), ethalon);
BOOST_CHECK_THROW(lexical_cast<ushort_arr_type>(val), boost::bad_lexical_cast);
}
{
sarr_type res1 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(&res1[0]), ethalon);
const sarr_type res2 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(&res2[0]), ethalon);
BOOST_CHECK_THROW(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
}
@@ -79,12 +79,12 @@ static void testing_template_array_output_on_spec_value(T val)
{
warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
BOOST_CHECK(&res[0] == wethalon);
}
{
const warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
BOOST_CHECK(&res[0] == wethalon);
}
BOOST_CHECK_THROW(lexical_cast<wshort_arr_type>(val), boost::bad_lexical_cast);
@@ -98,12 +98,12 @@ static void testing_template_array_output_on_spec_value(T val)
{
u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
BOOST_CHECK(&res[0] == u16ethalon);
}
{
const u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
BOOST_CHECK(&res[0] == u16ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u16short_arr_type>(val), boost::bad_lexical_cast);
@@ -116,12 +116,12 @@ static void testing_template_array_output_on_spec_value(T val)
{
u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
BOOST_CHECK(&res[0] == u32ethalon);
}
{
const u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
BOOST_CHECK(&res[0] == u32ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u32short_arr_type>(val), boost::bad_lexical_cast);
@@ -145,25 +145,25 @@ static void testing_template_array_output_on_char_value()
{
arr_type res1 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res1.begin(), ethalon);
BOOST_CHECK_EQUAL(&res1[0], ethalon);
const arr_type res2 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res2.begin(), ethalon);
BOOST_CHECK_EQUAL(&res2[0], ethalon);
BOOST_CHECK_THROW(lexical_cast<short_arr_type>(val), boost::bad_lexical_cast);
}
{
uarr_type res1 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(&res1[0]), ethalon);
const uarr_type res2 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(&res2[0]), ethalon);
BOOST_CHECK_THROW(lexical_cast<ushort_arr_type>(val), boost::bad_lexical_cast);
}
{
sarr_type res1 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(&res1[0]), ethalon);
const sarr_type res2 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(&res2[0]), ethalon);
BOOST_CHECK_THROW(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
}
@@ -174,16 +174,16 @@ static void testing_template_array_output_on_char_value()
{
warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
BOOST_CHECK(&res[0] == wethalon);
warr_type res3 = lexical_cast<warr_type>(wethalon);
BOOST_CHECK(res3.begin() == wethalon);
BOOST_CHECK(&res3[0] == wethalon);
}
{
const warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
BOOST_CHECK(&res[0] == wethalon);
const warr_type res3 = lexical_cast<warr_type>(wethalon);
BOOST_CHECK(res3.begin() == wethalon);
BOOST_CHECK(&res3[0] == wethalon);
}
BOOST_CHECK_THROW(lexical_cast<wshort_arr_type>(val), boost::bad_lexical_cast);
@@ -198,20 +198,20 @@ static void testing_template_array_output_on_char_value()
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
BOOST_CHECK(&res[0] == u16ethalon);
#endif
u16arr_type res3 = lexical_cast<u16arr_type>(u16ethalon);
BOOST_CHECK(res3.begin() == u16ethalon);
BOOST_CHECK(&res3[0] == u16ethalon);
}
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
const u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
BOOST_CHECK(&res[0] == u16ethalon);
#endif
const u16arr_type res3 = lexical_cast<u16arr_type>(u16ethalon);
BOOST_CHECK(res3.begin() == u16ethalon);
BOOST_CHECK(&res3[0] == u16ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u16short_arr_type>(val), boost::bad_lexical_cast);
@@ -225,19 +225,19 @@ static void testing_template_array_output_on_char_value()
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
BOOST_CHECK(&res[0] == u32ethalon);
#endif
u32arr_type res3 = lexical_cast<u32arr_type>(u32ethalon);
BOOST_CHECK(res3.begin() == u32ethalon);
BOOST_CHECK(&res3[0] == u32ethalon);
}
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
const u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
BOOST_CHECK(&res[0] == u32ethalon);
#endif
const u32arr_type res3 = lexical_cast<u32arr_type>(u32ethalon);
BOOST_CHECK(res3.begin() == u32ethalon);
BOOST_CHECK(&res3[0] == u32ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u32short_arr_type>(val), boost::bad_lexical_cast);
@@ -256,7 +256,7 @@ void testing_boost_array_output_conversion()
void testing_std_array_output_conversion()
{
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
testing_template_array_output_on_char_value<std::array>();
testing_template_array_output_on_spec_value<std::array>(100);
testing_template_array_output_on_spec_value<std::array>(static_cast<short>(100));
@@ -358,7 +358,7 @@ void testing_boost_array_input_conversion()
void testing_std_array_input_conversion()
{
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
testing_generic_array_input_conversion<std::array>();
#endif

View File

@@ -97,7 +97,10 @@ void test_metafunctions()
test_optimized_types_to_string<__int64>();
#endif
#if !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__)
test_optimized_types_to_string<float>();
#endif
test_optimized_types_to_string<std::string>();
test_optimized_types_to_string<char*>();
//test_optimized_types_to_string<char[5]>();
@@ -128,7 +131,7 @@ void test_metafunctions()
test_optimized_types_to_string_const<boost::iterator_range<const unsigned char*> >();
test_optimized_types_to_string_const<boost::iterator_range<const signed char*> >();
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#ifndef BOOST_NO_CXX11_HDR_ARRAY
test_optimized_types_to_string<std::array<char, 1> >();
test_optimized_types_to_string<std::array<char, 5> >();
test_optimized_types_to_string<std::array<unsigned char, 1> >();