Merge from trunk r75937

* fixed a lot of wchar_t errors
* Optimizations for boost::containers::basic_string
* More tests

[SVN r76062]
This commit is contained in:
Antony Polukhin
2011-12-19 15:19:43 +00:00
parent 1eda87448e
commit 7112ded1b9
15 changed files with 222 additions and 18 deletions
+82 -8
View File
@@ -17,7 +17,8 @@
// 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 and other Boosters
// Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann,
// Cheng Yang and other Boosters
// when: November 2000, March 2003, June 2005, June 2006, March 2011
#include <climits>
@@ -46,8 +47,10 @@
#include <boost/static_assert.hpp>
#include <boost/detail/lcast_precision.hpp>
#include <boost/detail/workaround.hpp>
#include <cwchar>
#include <boost/container/container_fwd.hpp>
#ifndef BOOST_NO_CWCHAR
# include <cwchar>
#endif
#ifndef BOOST_NO_STD_LOCALE
# include <locale>
@@ -145,6 +148,12 @@ namespace boost
{
typedef CharT type;
};
template<class CharT, class Traits, class Alloc>
struct stream_char< ::boost::container::basic_string<CharT,Traits,Alloc> >
{
typedef CharT type;
};
#endif
#ifndef BOOST_LCAST_NO_WCHAR_T
@@ -259,6 +268,24 @@ namespace boost
typedef Traits type;
};
template<class CharT, class Traits, class Alloc, class Source>
struct deduce_char_traits< CharT
, ::boost::container::basic_string<CharT,Traits,Alloc>
, Source
>
{
typedef Traits type;
};
template<class CharT, class Target, class Traits, class Alloc>
struct deduce_char_traits< CharT
, Target
, ::boost::container::basic_string<CharT,Traits,Alloc>
>
{
typedef Traits type;
};
template<class CharT, class Traits, class Alloc1, class Alloc2>
struct deduce_char_traits< CharT
, std::basic_string<CharT,Traits,Alloc1>
@@ -267,6 +294,15 @@ namespace boost
{
typedef Traits type;
};
template<class CharT, class Traits, class Alloc1, class Alloc2>
struct deduce_char_traits< CharT
, ::boost::container::basic_string<CharT,Traits,Alloc1>
, ::boost::container::basic_string<CharT,Traits,Alloc2>
>
{
typedef Traits type;
};
#endif
}
@@ -648,8 +684,8 @@ namespace boost
, const CharT opening_brace, const CharT closing_brace)
{
using namespace std;
const wchar_t minus = lcast_char_constants<wchar_t>::minus;
const wchar_t plus = lcast_char_constants<wchar_t>::plus;
const CharT minus = lcast_char_constants<CharT>::minus;
const CharT plus = lcast_char_constants<CharT>::plus;
const int inifinity_size = 8;
bool has_minus = false;
@@ -1257,6 +1293,14 @@ namespace boost
return true;
}
template<class Alloc>
bool operator<<(::boost::container::basic_string<CharT,Traits,Alloc> const& str)
{
start = const_cast<CharT*>(str.data());
finish = start + str.length();
return true;
}
bool operator<<(bool value)
{
CharT const czero = lcast_char_constants<CharT>::zero;
@@ -1310,6 +1354,7 @@ namespace boost
/************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/
private:
template <typename Type>
bool shr_unsigned(Type& output)
{
@@ -1436,7 +1481,7 @@ namespace boost
}
/************************************ OPERATORS >> ( ... ) ********************************/
public:
public:
bool operator>>(unsigned short& output) { return shr_unsigned(output); }
bool operator>>(unsigned int& output) { return shr_unsigned(output); }
bool operator>>(unsigned long int& output) { return shr_unsigned(output); }
@@ -1449,11 +1494,19 @@ namespace boost
#elif defined(BOOST_HAS_MS_INT64)
bool operator>>(unsigned __int64& output) { return shr_unsigned(output); }
bool operator>>(__int64& output) { return shr_signed(output); }
#endif
bool operator>>(CharT& output) { return shr_xchar(output); }
bool operator>>(char& output) { return shr_xchar(output); }
bool operator>>(unsigned char& output) { return shr_xchar(output); }
bool operator>>(signed char& output) { return shr_xchar(output); }
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
bool operator>>(wchar_t& output) { return shr_xchar(output); }
#endif
#ifndef BOOST_NO_CHAR16_T
bool operator>>(char16_t& output) { return shr_xchar(output); }
#endif
#ifndef BOOST_NO_CHAR32_T
bool operator>>(char32_t& output) { return shr_xchar(output); }
#endif
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
bool operator>>(std::string& str) { str.assign(start, finish); return true; }
# ifndef BOOST_LCAST_NO_WCHAR_T
@@ -1462,6 +1515,9 @@ namespace boost
#else
template<class Alloc>
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; }
#endif
/*
* case "-0" || "0" || "+0" : output = false; return true;
@@ -1598,6 +1654,12 @@ namespace boost
BOOST_STATIC_CONSTANT(bool, value = true );
};
template<typename CharT, typename Traits, typename Alloc>
struct is_stdstring< ::boost::container::basic_string<CharT, Traits, Alloc> >
{
BOOST_STATIC_CONSTANT(bool, value = true );
};
template<typename T>
struct is_char_or_wchar
{
@@ -1698,6 +1760,18 @@ namespace boost
BOOST_STATIC_CONSTANT(bool, value = true );
};
template<typename CharT, typename Traits, typename Alloc>
struct is_char_array_to_stdstring< ::boost::container::basic_string<CharT, Traits, Alloc>, CharT* >
{
BOOST_STATIC_CONSTANT(bool, value = true );
};
template<typename CharT, typename Traits, typename Alloc>
struct is_char_array_to_stdstring< ::boost::container::basic_string<CharT, Traits, Alloc>, const CharT* >
{
BOOST_STATIC_CONSTANT(bool, value = true );
};
#if (defined _MSC_VER)
# pragma warning( push )
# pragma warning( disable : 4701 ) // possible use of ... before initialization