From d1c2c5ce3fe69f52bfe6065fedfe759c6a821445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Tue, 24 Jun 2008 15:37:59 +0000 Subject: [PATCH] bug-fixes from trunk [SVN r46647] --- include/boost/range/as_literal.hpp | 24 ++++------ include/boost/range/begin.hpp | 8 ++-- include/boost/range/detail/as_literal.hpp | 4 +- .../range/detail/implementation_help.hpp | 4 ++ include/boost/range/end.hpp | 8 ++-- include/boost/range/iterator_range.hpp | 46 +++++++++++++------ include/boost/range/sub_range.hpp | 26 ++++++++--- 7 files changed, 74 insertions(+), 46 deletions(-) mode change 100755 => 100644 include/boost/range/as_literal.hpp mode change 100755 => 100644 include/boost/range/begin.hpp mode change 100755 => 100644 include/boost/range/detail/as_literal.hpp mode change 100755 => 100644 include/boost/range/detail/implementation_help.hpp mode change 100755 => 100644 include/boost/range/end.hpp mode change 100755 => 100644 include/boost/range/iterator_range.hpp mode change 100755 => 100644 include/boost/range/sub_range.hpp diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp old mode 100755 new mode 100644 index b0d7593..38cc9cf --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -8,8 +8,8 @@ // For more information, see http://www.boost.org/libs/range/ // -#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP -#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP +#ifndef BOOST_RANGE_AS_LITERAL_HPP +#define BOOST_RANGE_AS_LITERAL_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once @@ -25,7 +25,9 @@ #include #include +#ifndef BOOST_NO_CWCHAR #include +#endif namespace boost { @@ -36,10 +38,12 @@ namespace boost return strlen( s ); } +#ifndef BOOST_NO_INTRINSIC_WCHAR_T inline std::size_t length( const wchar_t* s ) { return wcslen( s ); } +#endif // // Remark: the compiler cannot choose between T* and T[sz] @@ -57,7 +61,7 @@ namespace boost return true; } - +#ifndef BOOST_NO_INTRINSIC_WCHAR_T inline bool is_char_ptr( wchar_t* ) { return true; @@ -67,6 +71,7 @@ namespace boost { return true; } +#endif template< class T > inline long is_char_ptr( T /* r */ ) @@ -107,22 +112,13 @@ namespace boost template< class Char, std::size_t sz > inline iterator_range as_literal( Char (&arr)[sz] ) { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 - return boost::make_iterator_range( arr, arr + sz - 1 ); -#else - return boost::make_iterator_range( arr, arr + sz - 1 ); -#endif + return range_detail::make_range( arr, range_detail::is_char_ptr(arr) ); } - template< class Char, std::size_t sz > inline iterator_range as_literal( const Char (&arr)[sz] ) { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590 - return boost::make_iterator_range( arr, arr + sz - 1 ); -#else - return boost::make_iterator_range( arr, arr + sz - 1 ); -#endif + return range_detail::make_range( arr, range_detail::is_char_ptr(arr) ); } } diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp old mode 100755 new mode 100644 index 9abf313..a4a5e10 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -73,15 +73,15 @@ namespace range_detail // May this be discarded? Or is it needed for bad compilers? // 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 > - inline T* range_begin( T (&array)[sz] ) + inline T* range_begin( T (&a)[sz] ) { - return array; + return a; } diff --git a/include/boost/range/detail/as_literal.hpp b/include/boost/range/detail/as_literal.hpp old mode 100755 new mode 100644 index b4fd925..0bd9a15 --- a/include/boost/range/detail/as_literal.hpp +++ b/include/boost/range/detail/as_literal.hpp @@ -8,8 +8,8 @@ // For more information, see http://www.boost.org/libs/range/ // -#ifndef BOOST_RANGE_AS_LITERAL_HPP -#define BOOST_RANGE_AS_LITERAL_HPP +#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP +#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp old mode 100755 new mode 100644 index da086f0..ca12fa4 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -25,6 +25,8 @@ namespace boost { namespace range_detail { + template + inline void boost_range_silence_warning( const T& ) { } ///////////////////////////////////////////////////////////////////// // end() help @@ -82,12 +84,14 @@ namespace boost template< class T, std::size_t sz > inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] ) { + boost_range_silence_warning( boost_range_array ); return sz; } template< class T, std::size_t sz > inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] ) { + boost_range_silence_warning( boost_range_array ); return sz; } diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp old mode 100755 new mode 100644 index b777a55..3063c02 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -71,15 +71,15 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// 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( array ); + return range_detail::array_end( a ); } 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( array ); + return range_detail::array_end( a ); } #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \ diff --git a/include/boost/range/iterator_range.hpp b/include/boost/range/iterator_range.hpp old mode 100755 new mode 100644 index 31b8ea8..d118224 --- a/include/boost/range/iterator_range.hpp +++ b/include/boost/range/iterator_range.hpp @@ -11,8 +11,15 @@ #ifndef 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 // Define __STL_CONFIG_H, if appropriate. +#include + +#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 # if defined(__STL_CONFIG_H) && \ !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ @@ -21,12 +28,13 @@ # endif #endif // #ifndef BOOST_OLD_IOSTREAMS -#include +#include +#include +#include #include #include #include -#include -#include +#include #include #include #ifndef _STLP_NO_IOSTREAMS @@ -38,10 +46,6 @@ #endif // _STLP_NO_IOSTREAMS #include -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) - #pragma warning( disable : 4996 ) -#endif - /*! \file Defines the \c iterator_class and related functions. \c iterator_range is a simple wrapper of iterator pair idiom. It provides @@ -163,6 +167,12 @@ namespace boost //! iterator type typedef IteratorT iterator; + private: // for return value of operator()() + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::if_< boost::is_abstract, + reference, value_type >::type abstract_value_type; + + public: iterator_range() : m_Begin( iterator() ), m_End( iterator() ) #ifndef NDEBUG , singular( true ) @@ -175,7 +185,7 @@ namespace boost m_Begin(Begin), m_End(End) #ifndef NDEBUG , singular(false) - #endif + #endif {} //! Constructor from a Range @@ -200,7 +210,7 @@ namespace boost template< class Range > iterator_range( const Range& r, iterator_range_detail::const_range_tag ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG + #ifndef NDEBUG , singular(false) #endif {} @@ -209,7 +219,7 @@ namespace boost template< class Range > iterator_range( Range& r, iterator_range_detail::range_tag ) : m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ) - #ifndef NDEBUG + #ifndef NDEBUG , singular(false) #endif {} @@ -350,8 +360,8 @@ namespace boost // When storing transform iterators, operator[]() // fails because it returns by reference. Therefore // 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() ); return m_Begin[at]; @@ -380,13 +390,15 @@ namespace boost bool singular; #endif - #ifndef NDEBUG public: bool is_singular() const { + #ifndef NDEBUG return singular; + #else + return false; + #endif } - #endif protected: // @@ -639,5 +651,9 @@ namespace boost #undef BOOST_OLD_IOSTREAMS +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning( pop ) +#endif + #endif diff --git a/include/boost/range/sub_range.hpp b/include/boost/range/sub_range.hpp old mode 100755 new mode 100644 index 35dfb27..dc66692 --- a/include/boost/range/sub_range.hpp +++ b/include/boost/range/sub_range.hpp @@ -11,18 +11,20 @@ #ifndef BOOST_RANGE_SUB_RANGE_HPP #define BOOST_RANGE_SUB_RANGE_HPP -#include - -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning( push ) #pragma warning( disable : 4996 ) #endif +#include #include #include #include #include #include #include +#include +#include namespace boost { @@ -41,12 +43,18 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME range_difference::type difference_type; typedef BOOST_DEDUCED_TYPENAME range_size::type size_type; typedef BOOST_DEDUCED_TYPENAME base::reference reference; + + public: // for return value of front/back + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::if_< boost::is_reference, + const BOOST_DEDUCED_TYPENAME boost::remove_reference::type&, + reference >::type const_reference; public: 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 ) : base( static_cast( r ) ) { } @@ -112,7 +120,7 @@ namespace boost return base::front(); } - const value_type& front() const + const_reference front() const { return base::front(); } @@ -122,7 +130,7 @@ namespace boost return base::back(); } - const value_type& back() const + const_reference back() const { return base::back(); } @@ -132,7 +140,7 @@ namespace boost return base::operator[](sz); } - const value_type& operator[]( difference_type sz ) const + const_reference operator[]( difference_type sz ) const { return base::operator[](sz); } @@ -163,5 +171,9 @@ namespace boost } // namespace 'boost' +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) + #pragma warning( pop ) +#endif + #endif