bug-fixes from trunk

[SVN r46647]
This commit is contained in:
Thorsten Jørgen Ottosen
2008-06-24 15:37:59 +00:00
parent 062e820882
commit d1c2c5ce3f
7 changed files with 74 additions and 46 deletions

24
include/boost/range/as_literal.hpp Executable file → Normal file
View File

@ -8,8 +8,8 @@
// For more information, see http://www.boost.org/libs/range/ // For more information, see http://www.boost.org/libs/range/
// //
#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP #ifndef BOOST_RANGE_AS_LITERAL_HPP
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP #define BOOST_RANGE_AS_LITERAL_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200) #if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once # pragma once
@ -25,7 +25,9 @@
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <cstring> #include <cstring>
#ifndef BOOST_NO_CWCHAR
#include <cwchar> #include <cwchar>
#endif
namespace boost namespace boost
{ {
@ -36,10 +38,12 @@ namespace boost
return strlen( s ); return strlen( s );
} }
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
inline std::size_t length( const wchar_t* s ) inline std::size_t length( const wchar_t* s )
{ {
return wcslen( s ); return wcslen( s );
} }
#endif
// //
// Remark: the compiler cannot choose between T* and T[sz] // Remark: the compiler cannot choose between T* and T[sz]
@ -57,7 +61,7 @@ namespace boost
return true; return true;
} }
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
inline bool is_char_ptr( wchar_t* ) inline bool is_char_ptr( wchar_t* )
{ {
return true; return true;
@ -67,6 +71,7 @@ namespace boost
{ {
return true; return true;
} }
#endif
template< class T > template< class T >
inline long is_char_ptr( T /* r */ ) inline long is_char_ptr( T /* r */ )
@ -107,22 +112,13 @@ namespace boost
template< class Char, std::size_t sz > template< class Char, std::size_t sz >
inline iterator_range<Char*> as_literal( Char (&arr)[sz] ) inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
{ {
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
return boost::make_iterator_range<Char*>( arr, arr + sz - 1 );
#else
return boost::make_iterator_range( arr, arr + sz - 1 );
#endif
} }
template< class Char, std::size_t sz > template< class Char, std::size_t sz >
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] ) inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
{ {
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
return boost::make_iterator_range<const Char*>( arr, arr + sz - 1 );
#else
return boost::make_iterator_range( arr, arr + sz - 1 );
#endif
} }
} }

8
include/boost/range/begin.hpp Executable file → Normal file
View File

@ -73,15 +73,15 @@ namespace range_detail
// May this be discarded? Or is it needed for bad compilers? // May this be discarded? Or is it needed for bad compilers?
// //
template< typename T, std::size_t sz > template< typename T, std::size_t sz >
inline const T* range_begin( const T (&array)[sz] ) inline const T* range_begin( const T (&a)[sz] )
{ {
return array; return a;
} }
template< typename T, std::size_t sz > template< typename T, std::size_t sz >
inline T* range_begin( T (&array)[sz] ) inline T* range_begin( T (&a)[sz] )
{ {
return array; return a;
} }

4
include/boost/range/detail/as_literal.hpp Executable file → Normal file
View File

@ -8,8 +8,8 @@
// For more information, see http://www.boost.org/libs/range/ // For more information, see http://www.boost.org/libs/range/
// //
#ifndef BOOST_RANGE_AS_LITERAL_HPP #ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
#define BOOST_RANGE_AS_LITERAL_HPP #define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200) #if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once # pragma once

4
include/boost/range/detail/implementation_help.hpp Executable file → Normal file
View File

@ -25,6 +25,8 @@ namespace boost
{ {
namespace range_detail namespace range_detail
{ {
template <typename T>
inline void boost_range_silence_warning( const T& ) { }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// end() help // end() help
@ -82,12 +84,14 @@ namespace boost
template< class T, std::size_t sz > template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] ) inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
{ {
boost_range_silence_warning( boost_range_array );
return sz; return sz;
} }
template< class T, std::size_t sz > template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] ) inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
{ {
boost_range_silence_warning( boost_range_array );
return sz; return sz;
} }

8
include/boost/range/end.hpp Executable file → Normal file
View File

@ -71,15 +71,15 @@ namespace range_detail
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz > template< typename T, std::size_t sz >
inline const T* range_end( const T (&array)[sz] ) inline const T* range_end( const T (&a)[sz] )
{ {
return range_detail::array_end<T,sz>( array ); return range_detail::array_end<T,sz>( a );
} }
template< typename T, std::size_t sz > template< typename T, std::size_t sz >
inline T* range_end( T (&array)[sz] ) inline T* range_end( T (&a)[sz] )
{ {
return range_detail::array_end<T,sz>( array ); return range_detail::array_end<T,sz>( a );
} }
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \

38
include/boost/range/iterator_range.hpp Executable file → Normal file
View File

@ -11,8 +11,15 @@
#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP #ifndef BOOST_RANGE_ITERATOR_RANGE_HPP
#define BOOST_RANGE_ITERATOR_RANGE_HPP #define BOOST_RANGE_ITERATOR_RANGE_HPP
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate. #include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( push )
#pragma warning( disable : 4996 )
#endif
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
#ifndef BOOST_OLD_IOSTREAMS #ifndef BOOST_OLD_IOSTREAMS
# if defined(__STL_CONFIG_H) && \ # if defined(__STL_CONFIG_H) && \
!defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
@ -21,12 +28,13 @@
# endif # endif
#endif // #ifndef BOOST_OLD_IOSTREAMS #endif // #ifndef BOOST_OLD_IOSTREAMS
#include <boost/detail/workaround.hpp> #include <boost/assert.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/is_abstract.hpp>
#include <boost/range/functions.hpp> #include <boost/range/functions.hpp>
#include <boost/range/iterator.hpp> #include <boost/range/iterator.hpp>
#include <boost/range/difference_type.hpp> #include <boost/range/difference_type.hpp>
#include <boost/iterator/iterator_traits.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/assert.hpp>
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
#ifndef _STLP_NO_IOSTREAMS #ifndef _STLP_NO_IOSTREAMS
@ -38,10 +46,6 @@
#endif // _STLP_NO_IOSTREAMS #endif // _STLP_NO_IOSTREAMS
#include <cstddef> #include <cstddef>
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400)
#pragma warning( disable : 4996 )
#endif
/*! \file /*! \file
Defines the \c iterator_class and related functions. Defines the \c iterator_class and related functions.
\c iterator_range is a simple wrapper of iterator pair idiom. It provides \c iterator_range is a simple wrapper of iterator pair idiom. It provides
@ -163,6 +167,12 @@ namespace boost
//! iterator type //! iterator type
typedef IteratorT iterator; typedef IteratorT iterator;
private: // for return value of operator()()
typedef BOOST_DEDUCED_TYPENAME
boost::mpl::if_< boost::is_abstract<value_type>,
reference, value_type >::type abstract_value_type;
public:
iterator_range() : m_Begin( iterator() ), m_End( iterator() ) iterator_range() : m_Begin( iterator() ), m_End( iterator() )
#ifndef NDEBUG #ifndef NDEBUG
, singular( true ) , singular( true )
@ -351,7 +361,7 @@ namespace boost
// fails because it returns by reference. Therefore // fails because it returns by reference. Therefore
// operator()() is provided for these cases. // operator()() is provided for these cases.
// //
value_type operator()( difference_type at ) const abstract_value_type operator()( difference_type at ) const
{ {
BOOST_ASSERT( at >= 0 && at < size() ); BOOST_ASSERT( at >= 0 && at < size() );
return m_Begin[at]; return m_Begin[at];
@ -380,13 +390,15 @@ namespace boost
bool singular; bool singular;
#endif #endif
#ifndef NDEBUG
public: public:
bool is_singular() const bool is_singular() const
{ {
#ifndef NDEBUG
return singular; return singular;
} #else
return false;
#endif #endif
}
protected: protected:
// //
@ -639,5 +651,9 @@ namespace boost
#undef BOOST_OLD_IOSTREAMS #undef BOOST_OLD_IOSTREAMS
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( pop )
#endif
#endif #endif

26
include/boost/range/sub_range.hpp Executable file → Normal file
View File

@ -11,18 +11,20 @@
#ifndef BOOST_RANGE_SUB_RANGE_HPP #ifndef BOOST_RANGE_SUB_RANGE_HPP
#define BOOST_RANGE_SUB_RANGE_HPP #define BOOST_RANGE_SUB_RANGE_HPP
#include <boost/detail/workaround.hpp> #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( push )
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400)
#pragma warning( disable : 4996 ) #pragma warning( disable : 4996 )
#endif #endif
#include <boost/detail/workaround.hpp>
#include <boost/range/config.hpp> #include <boost/range/config.hpp>
#include <boost/range/iterator_range.hpp> #include <boost/range/iterator_range.hpp>
#include <boost/range/value_type.hpp> #include <boost/range/value_type.hpp>
#include <boost/range/size_type.hpp> #include <boost/range/size_type.hpp>
#include <boost/range/difference_type.hpp> #include <boost/range/difference_type.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost namespace boost
{ {
@ -42,11 +44,17 @@ namespace boost
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type; typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
typedef BOOST_DEDUCED_TYPENAME base::reference reference; typedef BOOST_DEDUCED_TYPENAME base::reference reference;
public: // for return value of front/back
typedef BOOST_DEDUCED_TYPENAME
boost::mpl::if_< boost::is_reference<reference>,
const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&,
reference >::type const_reference;
public: public:
sub_range() : base() sub_range() : base()
{ } { }
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
sub_range( const sub_range& r ) sub_range( const sub_range& r )
: base( static_cast<const base&>( r ) ) : base( static_cast<const base&>( r ) )
{ } { }
@ -112,7 +120,7 @@ namespace boost
return base::front(); return base::front();
} }
const value_type& front() const const_reference front() const
{ {
return base::front(); return base::front();
} }
@ -122,7 +130,7 @@ namespace boost
return base::back(); return base::back();
} }
const value_type& back() const const_reference back() const
{ {
return base::back(); return base::back();
} }
@ -132,7 +140,7 @@ namespace boost
return base::operator[](sz); return base::operator[](sz);
} }
const value_type& operator[]( difference_type sz ) const const_reference operator[]( difference_type sz ) const
{ {
return base::operator[](sz); return base::operator[](sz);
} }
@ -163,5 +171,9 @@ namespace boost
} // namespace 'boost' } // namespace 'boost'
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( pop )
#endif
#endif #endif