Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2008-06-24 11:37:59


Author: nesotto
Date: 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
New Revision: 46647
URL: http://svn.boost.org/trac/boost/changeset/46647

Log:
bug-fixes from trunk
Text files modified:
   branches/release/boost/range/as_literal.hpp | 24 ++++++++------------
   branches/release/boost/range/begin.hpp | 8 +++---
   branches/release/boost/range/detail/as_literal.hpp | 4 +-
   branches/release/boost/range/detail/implementation_help.hpp | 4 +++
   branches/release/boost/range/end.hpp | 8 +++---
   branches/release/boost/range/iterator_range.hpp | 46 ++++++++++++++++++++++++++-------------
   branches/release/boost/range/sub_range.hpp | 26 ++++++++++++++++------
   7 files changed, 74 insertions(+), 46 deletions(-)

Modified: branches/release/boost/range/as_literal.hpp
==============================================================================
--- branches/release/boost/range/as_literal.hpp (original)
+++ branches/release/boost/range/as_literal.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -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 <boost/detail/workaround.hpp>
 
 #include <cstring>
+#ifndef BOOST_NO_CWCHAR
 #include <cwchar>
+#endif
 
 namespace boost
 {
@@ -36,10 +38,12 @@
             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 @@
             return true;
         }
 
-
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
         inline bool is_char_ptr( wchar_t* )
         {
             return true;
@@ -67,6 +71,7 @@
         {
             return true;
         }
+#endif
         
         template< class T >
         inline long is_char_ptr( T /* r */ )
@@ -107,22 +112,13 @@
     template< class Char, std::size_t sz >
     inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
     {
-#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
- return boost::make_iterator_range<Char*>( 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<const Char*> as_literal( const Char (&arr)[sz] )
     {
-#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
- return boost::make_iterator_range<const Char*>( 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) );
     }
 }
 

Modified: branches/release/boost/range/begin.hpp
==============================================================================
--- branches/release/boost/range/begin.hpp (original)
+++ branches/release/boost/range/begin.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -73,15 +73,15 @@
     // 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;
     }
 
 

Modified: branches/release/boost/range/detail/as_literal.hpp
==============================================================================
--- branches/release/boost/range/detail/as_literal.hpp (original)
+++ branches/release/boost/range/detail/as_literal.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -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

Modified: branches/release/boost/range/detail/implementation_help.hpp
==============================================================================
--- branches/release/boost/range/detail/implementation_help.hpp (original)
+++ branches/release/boost/range/detail/implementation_help.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -25,6 +25,8 @@
 {
     namespace range_detail
     {
+ template <typename T>
+ inline void boost_range_silence_warning( const T& ) { }
         
         /////////////////////////////////////////////////////////////////////
         // end() help
@@ -82,12 +84,14 @@
         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;
         }
 

Modified: branches/release/boost/range/end.hpp
==============================================================================
--- branches/release/boost/range/end.hpp (original)
+++ branches/release/boost/range/end.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -71,15 +71,15 @@
         //////////////////////////////////////////////////////////////////////
 
         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 >
- 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)) && \

Modified: branches/release/boost/range/iterator_range.hpp
==============================================================================
--- branches/release/boost/range/iterator_range.hpp (original)
+++ branches/release/boost/range/iterator_range.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -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 <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
 # if defined(__STL_CONFIG_H) && \
     !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
@@ -21,12 +28,13 @@
 # endif
 #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/iterator.hpp>
 #include <boost/range/difference_type.hpp>
-#include <boost/iterator/iterator_traits.hpp>
-#include <boost/assert.hpp>
+#include <boost/utility/enable_if.hpp>
 #include <iterator>
 #include <algorithm>
 #ifndef _STLP_NO_IOSTREAMS
@@ -38,10 +46,6 @@
 #endif // _STLP_NO_IOSTREAMS
 #include <cstddef>
 
-#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 @@
             //! iterator type
             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() )
                 #ifndef NDEBUG
             , singular( true )
@@ -175,7 +185,7 @@
                 m_Begin(Begin), m_End(End)
                 #ifndef NDEBUG
             , singular(false)
- #endif
+ #endif
             {}
 
             //! Constructor from a Range
@@ -200,7 +210,7 @@
             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 @@
             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 @@
            // 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 @@
             bool singular;
             #endif
 
- #ifndef NDEBUG
         public:
             bool is_singular() const
             {
+ #ifndef NDEBUG
                  return singular;
+ #else
+ return false;
+ #endif
             }
- #endif
 
         protected:
             //
@@ -639,5 +651,9 @@
 
 #undef BOOST_OLD_IOSTREAMS
 
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+ #pragma warning( pop )
+#endif
+
 #endif
 

Modified: branches/release/boost/range/sub_range.hpp
==============================================================================
--- branches/release/boost/range/sub_range.hpp (original)
+++ branches/release/boost/range/sub_range.hpp 2008-06-24 11:37:59 EDT (Tue, 24 Jun 2008)
@@ -11,18 +11,20 @@
 #ifndef BOOST_RANGE_SUB_RANGE_HPP
 #define BOOST_RANGE_SUB_RANGE_HPP
 
-#include <boost/detail/workaround.hpp>
-
-#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 <boost/detail/workaround.hpp>
 #include <boost/range/config.hpp>
 #include <boost/range/iterator_range.hpp>
 #include <boost/range/value_type.hpp>
 #include <boost/range/size_type.hpp>
 #include <boost/range/difference_type.hpp>
 #include <boost/assert.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 
 namespace boost
 {
@@ -41,12 +43,18 @@
         typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
         typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::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<reference>,
+ const BOOST_DEDUCED_TYPENAME boost::remove_reference<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<const base&>( r ) )
         { }
@@ -112,7 +120,7 @@
             return base::front();
         }
 
- const value_type& front() const
+ const_reference front() const
         {
             return base::front();
         }
@@ -122,7 +130,7 @@
             return base::back();
         }
 
- const value_type& back() const
+ const_reference back() const
         {
             return base::back();
         }
@@ -132,7 +140,7 @@
             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'
 
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+ #pragma warning( pop )
+#endif
+
 #endif
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk