Compare commits

..

1 Commits

Author SHA1 Message Date
4300becb58 This commit was manufactured by cvs2svn to create branch 'SPIRIT_1_6'.
[SVN r23968]
2004-07-23 02:16:28 +00:00
40 changed files with 535 additions and 2938 deletions

View File

@ -8,26 +8,16 @@
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_HPP_27_07_04
#define BOOST_RANGE_HPP_27_07_04
#ifndef BOOST_RANGE_HPP
#define BOOST_RANGE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#if _MSC_VER == 1300 // experiment
#include <boost/range/detail/collection_traits.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/sub_range.hpp>
#else
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/range/types.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/sub_range.hpp>
#endif // _MSC_VER == 1300 // experiment
#endif

View File

@ -24,171 +24,92 @@
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
namespace boost
namespace boost
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
namespace range_detail
namespace range
{
#endif
//////////////////////////////////////////////////////////////////////
// primary template
// default
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
boost_range_begin( const C& c )
inline BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type
begin( const C& c )
{
return c.begin();
return c.begin();
}
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
boost_range_begin( C& c )
inline BOOST_DEDUCED_TYPENAME iterator_of<C>::type
begin( C& c )
{
return c.begin();
return c.begin();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator boost_range_begin( const std::pair<Iterator,Iterator>& p )
inline Iterator begin( const std::pair<Iterator,Iterator>& p )
{
return p.first;
}
template< typename Iterator >
inline Iterator boost_range_begin( std::pair<Iterator,Iterator>& p )
inline Iterator begin( std::pair<Iterator,Iterator>& p )
{
return p.first;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline const T* boost_range_begin( const T (&array)[sz] )
inline const T* begin( const T (&array)[sz] )
{
return array;
}
template< typename T, std::size_t sz >
inline T* boost_range_begin( T (&array)[sz] )
inline T* begin( T (&array)[sz] )
{
return array;
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// CW up to 9.3 and borland have troubles with function ordering
inline const char* boost_range_begin( const char* s )
inline const char* begin( const char* s )
{
return s;
}
inline char* begin( char* s )
{
return s;
}
inline const wchar_t* begin( const wchar_t* s )
{
return s;
}
inline wchar_t* begin( wchar_t* s )
{
return s;
}
inline char* boost_range_begin( char* s )
{
return s;
}
} // namespace 'range'
inline const wchar_t* boost_range_begin( const wchar_t* s )
{
return s;
}
inline wchar_t* boost_range_begin( wchar_t* s )
{
return s;
}
#else
inline const char* boost_range_begin( const char*& s )
{
return s;
}
inline char* boost_range_begin( char*& s )
{
return s;
}
inline const wchar_t* boost_range_begin( const wchar_t*& s )
{
return s;
}
inline wchar_t* boost_range_begin( wchar_t*& s )
{
return s;
}
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
} // namespace 'range_detail'
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_begin( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type begin( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_begin( r );
}
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB and CW are not able to overload pointer when class overloads are also available.
template<>
inline range_const_iterator<const char*>::type begin<const char*>( const char*& r )
{
return r;
}
template<>
inline range_const_iterator<const wchar_t*>::type begin<const wchar_t*>( const wchar_t*& r )
{
return r;
}
#endif
using range::begin;
} // namespace boost
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
const_begin( const T& r )
{
return begin( r );
}
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif

View File

@ -11,42 +11,35 @@
#ifndef BOOST_RANGE_CONFIG_HPP
#define BOOST_RANGE_CONFIG_HPP
#include <boost/detail/workaround.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#ifdef BOOST_RANGE_DEDUCED_TYPENAME
#ifdef BOOST_CT_DEDUCED_TYPENAME
#error "macro already defined!"
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# define BOOST_RANGE_DEDUCED_TYPENAME typename
#ifdef __BORLANDC__
#define BOOST_CT_DEDUCED_TYPENAME
#else
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) && !defined(_MSC_EXTENSIONS)
# define BOOST_RANGE_DEDUCED_TYPENAME typename
# else
# define BOOST_RANGE_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
# endif
#define BOOST_CT_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
#endif
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
#ifdef BOOST_CT_NO_ARRAY_SUPPORT
#error "macro already defined!"
#endif
//#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || __MWERKS__ <= 0x3003
#if _MSC_VER <= 1300 && !defined( __COMO__ ) && !defined( __GNUC__ ) && __MWERKS__ <= 0x3003
#define BOOST_RANGE_NO_ARRAY_SUPPORT 1
#if _MSC_VER <= 1200 && !defined( __COMO__ ) && !defined( _GNUC_ )
#define BOOST_CT_NO_ARRAY_SUPPORT
#endif
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
#define BOOST_RANGE_ARRAY_REF() (boost_range_array)
#define BOOST_RANGE_NO_STATIC_ASSERT
#ifdef BOOST_CT_NO_ARRAY_SUPPORT
#define BOOST_ARRAY_REF (array)
#define BOOST_CT_NO_STATIC_ASSERT
#else
#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
#define BOOST_ARRAY_REF (&array)
#endif

View File

@ -31,7 +31,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_const_iterator
struct const_iterator_of
{
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
};
@ -41,13 +41,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_const_iterator< std::pair<Iterator,Iterator> >
struct const_iterator_of< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
template< typename Iterator >
struct range_const_iterator< const std::pair<Iterator,Iterator> >
struct const_iterator_of< const std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
@ -57,13 +57,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_const_iterator< T[sz] >
struct const_iterator_of< T[sz] >
{
typedef const T* type;
};
template< typename T, std::size_t sz >
struct range_const_iterator< const T[sz] >
struct const_iterator_of< const T[sz] >
{
typedef const T* type;
};
@ -73,49 +73,25 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct range_const_iterator< char* >
struct const_iterator_of< char* >
{
typedef const char* type;
};
template<>
struct range_const_iterator< wchar_t* >
struct const_iterator_of< wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct range_const_iterator< const char* >
struct const_iterator_of< const char* >
{
typedef const char* type;
};
template<>
struct range_const_iterator< const wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct range_const_iterator< char* const >
{
typedef const char* type;
};
template<>
struct range_const_iterator< wchar_t* const >
{
typedef const wchar_t* type;
};
template<>
struct range_const_iterator< const char* const >
{
typedef const char* type;
};
template<>
struct range_const_iterator< const wchar_t* const >
struct const_iterator_of< const wchar_t* >
{
typedef const wchar_t* type;
};

View File

@ -26,10 +26,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_const_reverse_iterator
struct const_reverse_iterator_of
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type > type;
BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type > type;
};
} // namespace boost

View File

@ -11,13 +11,8 @@
#ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
#define BOOST_RANGE_DETAIL_BEGIN_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/value_type.hpp>
#endif
namespace boost
{
@ -35,7 +30,7 @@ namespace boost
struct range_begin<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type fun( C& c )
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<C>::type fun( C& c )
{
return c.begin();
};
@ -49,7 +44,7 @@ namespace boost
struct range_begin<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type fun( const P& p )
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<P>::type fun( const P& p )
{
return p.first;
}
@ -62,19 +57,11 @@ namespace boost
template<>
struct range_begin<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static T* fun( T BOOST_ARRAY_REF[sz] )
{
return boost_range_array;
return array;
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
{
return t;
}
#endif
};
//////////////////////////////////////////////////////////////////////
@ -118,13 +105,13 @@ namespace boost
}
};
} // namespace 'range_detail'
} // namespace 'range_traits_detail'
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
inline BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type
begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
return range_traits_detail::range_begin< BOOST_DEDUCED_TYPENAME range_traits_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'

View File

@ -1,266 +0,0 @@
// Boost string_algo library collection_traits.hpp header file -------------//
// Copyright Pavol Droba 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// (C) Copyright Thorsten Ottosen 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// (C) Copyright Jeremy Siek 2001. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Original idea of container traits was proposed by Jeremy Siek and
// Thorsten Ottosen. This implementation is lightweighted version
// of container_traits adapter for usage with string_algo library
#ifndef BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
#define BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/mpl/eval_if.hpp>
// Implementation
#include <boost/range/detail/collection_traits_detail.hpp>
/*! \file
Defines collection_traits class and related free-standing functions.
This facility is used to unify the access to different types of collections.
It allows the algorithms in the library to work with STL collections, c-style
array, null-terminated c-strings (and more) using the same interface.
*/
namespace boost {
namespace algorithm {
// collection_traits template class -----------------------------------------//
//! collection_traits class
/*!
Collection traits provide uniform access to different types of
collections. This functionality allows to write generic algorithms
which work with several different kinds of collections.
Currently following collection types are supported:
- containers with STL compatible container interface ( see ContainerConcept )
( i.e. \c std::vector<>, \c std::list<>, \c std::string<> ... )
- c-style array
( \c char[10], \c int[15] ... )
- null-terminated c-strings
( \c char*, \c wchar_T* )
- std::pair of iterators
( i.e \c std::pair<vector<int>::iterator,vector<int>::iterator> )
Collection traits provide an external collection interface operations.
All are accessible using free-standing functions.
The following operations are supported:
- \c size()
- \c empty()
- \c begin()
- \c end()
Container traits have somewhat limited functionality on compilers not
supporting partial template specialization and partial template ordering.
*/
template< typename T >
struct collection_traits
{
private:
typedef BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
::boost::algorithm::detail::is_pair<T>,
detail::pair_container_traits_selector<T>,
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
::boost::is_array<T>,
detail::array_container_traits_selector<T>,
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
::boost::is_pointer<T>,
detail::pointer_container_traits_selector<T>,
detail::default_container_traits_selector<T>
>
>
>::type container_helper_type;
public:
//! Function type
typedef container_helper_type function_type;
//! Value type
typedef BOOST_STRING_TYPENAME
container_helper_type::value_type value_type;
//! Size type
typedef BOOST_STRING_TYPENAME
container_helper_type::size_type size_type;
//! Iterator type
typedef BOOST_STRING_TYPENAME
container_helper_type::iterator iterator;
//! Const iterator type
typedef BOOST_STRING_TYPENAME
container_helper_type::const_iterator const_iterator;
//! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
typedef BOOST_STRING_TYPENAME
container_helper_type::result_iterator result_iterator;
//! Difference type
typedef BOOST_STRING_TYPENAME
container_helper_type::difference_type difference_type;
}; // 'collection_traits'
// collection_traits metafunctions -----------------------------------------//
//! Container value_type trait
/*!
Extract the type of elements contained in a container
*/
template< typename C >
struct value_type_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::value_type type;
};
//! Container difference trait
/*!
Extract the container's difference type
*/
template< typename C >
struct difference_type_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::difference_type type;
};
//! Container iterator trait
/*!
Extract the container's iterator type
*/
template< typename C >
struct iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::iterator type;
};
//! Container const_iterator trait
/*!
Extract the container's const_iterator type
*/
template< typename C >
struct const_iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::const_iterator type;
};
//! Container result_iterator
/*!
Extract the container's result_iterator type. This type maps to \c C::iterator
for mutable container and \c C::const_iterator for const containers.
*/
template< typename C >
struct result_iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::result_iterator type;
};
// collection_traits related functions -----------------------------------------//
//! Free-standing size() function
/*!
Get the size of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::size_type
size( const C& c )
{
return collection_traits<C>::function_type::size( c );
}
//! Free-standing empty() function
/*!
Check whether the container is empty. Uses container traits.
*/
template< typename C >
inline bool empty( const C& c )
{
return collection_traits<C>::function_type::empty( c );
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//! Free-standing begin() function
/*!
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
begin( C& c )
{
return collection_traits<C>::function_type::begin( c );
}
//! Free-standing begin() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
begin( const C& c )
{
return collection_traits<C>::function_type::begin( c );
}
//! Free-standing end() function
/*!
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
end( C& c )
{
return collection_traits<C>::function_type::end( c );
}
//! Free-standing end() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
end( const C& c )
{
return collection_traits<C>::function_type::end( c );
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//! Free-standing begin() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
begin( C& c )
{
return collection_traits<C>::function_type::begin( c );
}
//! Free-standing end() function
/*!
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
end( C& c )
{
return collection_traits<C>::function_type::end( c );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
} // namespace algorithm
} // namespace boost
#endif // BOOST_STRING_COLLECTION_TRAITS_HPP

View File

@ -1,621 +0,0 @@
// Boost string_algo library collection_traits.hpp header file -----------------------//
// Copyright Pavol Droba 2002-2003. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
#define BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
#include <boost/algorithm/string/config.hpp>
#include <cstddef>
#include <string>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/algorithm/string/yes_no_type.hpp>
// Container traits implementation ---------------------------------------------------------
namespace boost {
namespace algorithm {
namespace detail {
// Default collection traits -----------------------------------------------------------------
// Default collection helper
/*
Wraps std::container compliant containers
*/
template< typename ContainerT >
struct default_container_traits
{
typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type;
typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator;
typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
::boost::mpl::if_< ::boost::is_const<ContainerT>,
const_iterator,
iterator
>::type result_iterator;
typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type;
typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type;
// static operations
template< typename C >
static size_type size( const C& c )
{
return c.size();
}
template< typename C >
static bool empty( const C& c )
{
return c.empty();
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename C >
static iterator begin( C& c )
{
return c.begin();
}
template< typename C >
static const_iterator begin( const C& c )
{
return c.begin();
}
template< typename C >
static iterator end( C& c )
{
return c.end();
}
template< typename C >
static const_iterator end( const C& c )
{
return c.end();
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename C >
static result_iterator begin( C& c )
{
return c.begin();
}
template< typename C >
static result_iterator end( C& c )
{
return c.end();
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
};
template<typename T>
struct default_container_traits_selector
{
typedef default_container_traits<T> type;
};
// Pair container traits ---------------------------------------------------------------------
// pair selector
template< typename T, typename U >
yes_type is_pair_impl( const std::pair<T,U>* );
no_type is_pair_impl( ... );
template<typename T> struct is_pair
{
private:
static T* t;
public:
BOOST_STATIC_CONSTANT( bool, value=
sizeof(is_pair_impl(t))==sizeof(yes_type) );
};
// pair helper
template< typename PairT >
struct pair_container_traits
{
typedef BOOST_STRING_TYPENAME PairT::first_type element_type;
typedef BOOST_STRING_TYPENAME ::boost::detail::
iterator_traits<element_type>::value_type value_type;
typedef std::size_t size_type;
typedef BOOST_STRING_TYPENAME ::boost::detail::
iterator_traits<element_type>::difference_type difference_type;
typedef element_type iterator;
typedef element_type const_iterator;
typedef element_type result_iterator;
// static operations
template< typename P >
static size_type size( const P& p )
{
difference_type diff = std::distance( p.first, p.second );
if ( diff < 0 )
return 0;
else
return diff;
}
template< typename P >
static bool empty( const P& p )
{
return p.first==p.second;
}
template< typename P >
static const_iterator begin( const P& p )
{
return p.first;
}
template< typename P >
static const_iterator end( const P& p )
{
return p.second;
}
}; // 'pair_container_helper'
template<typename T>
struct pair_container_traits_selector
{
typedef pair_container_traits<T> type;
};
// Array container traits ---------------------------------------------------------------
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// array traits ( partial specialization )
template< typename T >
struct array_traits;
template< typename T, std::size_t sz >
struct array_traits<T[sz]>
{
// typedef
typedef T* iterator;
typedef const T* const_iterator;
typedef T value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// size of the array ( static );
BOOST_STATIC_CONSTANT( size_type, array_size = sz );
};
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// array traits ( no partial specialization )
/*
without parial specialization we are able to
provide support only for a limited number of
types. Currently the primitive numeric types
are supported
*/
template< typename T, typename BaseT >
struct array_traits_impl
{
typedef BaseT value_type;
typedef BaseT* iterator;
typedef const BaseT* const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
// size of the array
BOOST_STATIC_CONSTANT( size_type, array_size = sizeof(T)/sizeof(BaseT) );
};
template< typename T, typename BaseT >
struct array_traits_impl_selector
{
typedef array_traits_impl<T,BaseT> type;
};
struct array_traits_void
{
typedef void type;
};
template< typename T, typename BaseT >
struct array_traits_cv_selector
{
typedef BOOST_STRING_TYPENAME
::boost::mpl::eval_if<
::boost::is_convertible<T,BaseT*>,
array_traits_impl_selector<T,BaseT>,
::boost::mpl::eval_if<
::boost::is_convertible<T,const BaseT*>,
array_traits_impl_selector<T, const BaseT>,
::boost::mpl::eval_if<
::boost::is_convertible<T, volatile BaseT*>,
array_traits_impl_selector<T, volatile BaseT>,
array_traits_impl_selector<T, const volatile BaseT>
>
>
>::type type;
};
template< typename T >
struct array_traits_select
{
template< typename T1, typename T2 >
struct apply
{
typedef BOOST_STRING_TYPENAME
::boost::mpl::eval_if<
::boost::is_convertible<T,const volatile T2*>,
array_traits_cv_selector<T,T2>,
::boost::mpl::identity<T1> >::type type;
};
};
template< typename T >
struct array_traits_selector
{
private:
// supported array base types
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
typedef BOOST_STRING_TYPENAME
::boost::mpl::vector10<
wchar_t,
#else // BOOST_NO_INTRINSIC_WCHAR_T
typedef BOOST_STRING_TYPENAME
::boost::mpl::vector9<
#endif // BOOST_NO_INTRINSIC_WCHAR_T
char,
signed char,
unsigned char,
signed short,
unsigned short,
signed int,
unsigned int,
signed long,
unsigned long
>::type array_base_types;
public:
typedef BOOST_STRING_TYPENAME
::boost::mpl::fold<
array_base_types,
::boost::algorithm::detail::array_traits_void,
::boost::algorithm::detail::array_traits_select<T> >::type type;
};
template< typename T >
struct array_traits
{
typedef BOOST_STRING_TYPENAME
array_traits_selector<T>::type traits_type;
typedef BOOST_STRING_TYPENAME
traits_type::value_type value_type;
typedef BOOST_STRING_TYPENAME
traits_type::iterator iterator;
typedef BOOST_STRING_TYPENAME
traits_type::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
traits_type::size_type size_type;
typedef BOOST_STRING_TYPENAME
traits_type::difference_type difference_type;
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// array lenght resolving
/*
Lenght of string contained in a static array could
be different from the size of the array.
For string processing we need the lenght without
terminating 0.
Therefore, the lenght is calulated for char and wchar_t
using char_traits, rather then simply returning
the array size.
*/
template< typename T >
struct array_length_selector
{
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
TraitsT::size_type size_type;
BOOST_STATIC_CONSTANT(
size_type,
array_size=TraitsT::array_size );
template< typename A >
static size_type length( const A& )
{
return array_size;
}
template< typename A >
static bool empty( const A& )
{
return array_size==0;
}
};
};
// specialization for char
template<>
struct array_length_selector<char>
{
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
TraitsT::size_type size_type;
template< typename A >
static size_type length( const A& a )
{
if ( a==0 )
return 0;
else
return std::char_traits<char>::length(a);
}
template< typename A >
static bool empty( const A& a )
{
return a==0 || a[0]==0;
}
};
};
// specialization for wchar_t
template<>
struct array_length_selector<wchar_t>
{
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
TraitsT::size_type size_type;
template< typename A >
static size_type length( const A& a )
{
if ( a==0 )
return 0;
else
return std::char_traits<wchar_t>::length(a);
}
template< typename A >
static bool empty( const A& a )
{
return a==0 || a[0]==0;
}
};
};
template< typename T >
struct array_container_traits
{
private:
// resolve array traits
typedef array_traits<T> traits_type;
public:
typedef BOOST_STRING_TYPENAME
traits_type::value_type value_type;
typedef BOOST_STRING_TYPENAME
traits_type::iterator iterator;
typedef BOOST_STRING_TYPENAME
traits_type::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
traits_type::size_type size_type;
typedef BOOST_STRING_TYPENAME
traits_type::difference_type difference_type;
typedef BOOST_STRING_TYPENAME
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator
>::type result_iterator;
private:
// resolve array size
typedef BOOST_STRING_TYPENAME
::boost::remove_cv<value_type>::type char_type;
typedef BOOST_STRING_TYPENAME
array_length_selector<char_type>::
BOOST_NESTED_TEMPLATE array_length<traits_type> array_length_type;
public:
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
// static operations
template< typename A >
static size_type size( const A& a )
{
return array_length_type::length(a);
}
template< typename A >
static bool empty( const A& a )
{
return array_length_type::empty(a);
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename A >
static iterator begin( A& a )
{
return a;
}
template< typename A >
static const_iterator begin( const A& a )
{
return a;
}
template< typename A >
static iterator end( A& a )
{
return a+array_length_type::length(a);
}
template< typename A >
static const_iterator end( const A& a )
{
return a+array_length_type::length(a);
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename A >
static result_iterator begin( A& a )
{
return a;
}
template< typename A >
static result_iterator end( A& a )
{
return a+array_length_type::length(a);
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
};
template<typename T>
struct array_container_traits_selector
{
typedef array_container_traits<T> type;
};
// Pointer container traits ---------------------------------------------------------------
template<typename T>
struct pointer_container_traits
{
typedef BOOST_STRING_TYPENAME
::boost::remove_pointer<T>::type value_type;
typedef BOOST_STRING_TYPENAME
::boost::remove_cv<value_type>::type char_type;
typedef ::std::char_traits<char_type> char_traits;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef BOOST_STRING_TYPENAME
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator
>::type result_iterator;
// static operations
template< typename P >
static size_type size( const P& p )
{
if ( p==0 )
return 0;
else
return char_traits::length(p);
}
template< typename P >
static bool empty( const P& p )
{
return p==0 || p[0]==0;
}
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename P >
static iterator begin( P& p )
{
return p;
}
template< typename P >
static const_iterator begin( const P& p )
{
return p;
}
template< typename P >
static iterator end( P& p )
{
if ( p==0 )
return p;
else
return p+char_traits::length(p);
}
template< typename P >
static const_iterator end( const P& p )
{
if ( p==0 )
return p;
else
return p+char_traits::length(p);
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename P >
static result_iterator begin( P& p )
{
return p;
}
template< typename P >
static result_iterator end( P& p )
{
if ( p==0 )
return p;
else
return p+char_traits::length(p);
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
};
template<typename T>
struct pointer_container_traits_selector
{
typedef pointer_container_traits<T> type;
};
} // namespace detail
} // namespace algorithm
} // namespace boost
#endif // BOOST_STRING_DETAIL_COLLECTION_HPP

View File

@ -17,6 +17,7 @@
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
#include <boost/mpl/if.hpp>
@ -58,7 +59,7 @@ namespace boost
typedef mpl::int_<12>::type string_;
template< typename C >
struct range_helper
struct collection_helper
{
static C* c;
static C ptr;
@ -78,35 +79,35 @@ namespace boost
template< typename C >
class range
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_pair_,
boost::range_detail::std_pair_,
void >::type pair_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_array_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_pair_,
boost::range_detail::std_pair_,
void >::type pair_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_array_,
boost::range_detail::array_,
pair_t >::type array_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_string_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_string_,
boost::range_detail::string_,
array_t >::type string_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_const_char_ptr_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_const_char_ptr_,
boost::range_detail::const_char_ptr_,
string_t >::type const_char_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_char_ptr_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_char_ptr_,
boost::range_detail::char_ptr_,
const_char_ptr_t >::type char_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_const_wchar_t_ptr_,
boost::range_detail::const_wchar_t_ptr_,
char_ptr_t >::type const_wchar_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_wchar_t_ptr_,
boost::range_detail::wchar_t_ptr_,
const_wchar_ptr_t >::type wchar_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_wchar_t_array_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_wchar_t_array_,
boost::range_detail::wchar_t_array_,
wchar_ptr_t >::type wchar_array_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_char_array_,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_char_array_,
boost::range_detail::char_array_,
wchar_array_t >::type char_array_t;
public:
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::is_void<char_array_t>::value,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::is_void<char_array_t>::value,
boost::range_detail::std_container_,
char_array_t >::type type;
}; // class 'range'

View File

@ -12,7 +12,6 @@
#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
@ -31,7 +30,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::const_iterator type;
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
};
};
@ -41,32 +40,12 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_const_iterator_<array_>
{
template< typename T >
struct pts
{
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_const_iterator_<char_array_>
{
template< typename T >
struct pts
{
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
struct range_const_iterator_<array_>; // give up
template<>
struct range_const_iterator_<char_ptr_>
@ -111,7 +90,7 @@ namespace boost
}
template< typename C >
class range_const_iterator
class const_iterator_of
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:

View File

@ -41,7 +41,7 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
typedef BOOST_CT_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
};
};
@ -55,16 +55,6 @@ namespace boost
};
};
template<>
struct range_difference_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<char_ptr_>
{
@ -108,11 +98,11 @@ namespace boost
}
template< typename C >
class range_difference
class difference_type_of
{
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
typedef BOOST_CT_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
typedef BOOST_CT_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}

View File

@ -18,14 +18,14 @@ namespace boost
namespace range_detail
{
template< typename T >
struct range_empty;
struct collection_empty;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<std_container_>
struct collection_empty<std_container_>
{
template< typename C >
static bool fun( C& c )
@ -39,7 +39,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<std_pair_>
struct collection_empty<std_pair_>
{
template< typename P >
static bool fun( const P& p )
@ -53,12 +53,12 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<array_>
struct collection_empty<array_>
{
template< typename T, std::size_t sz >
static bool fun( T BOOST_ARRAY_REF[sz] )
{
if( boost_range_array == 0 )
if( array == 0 )
return true;
return false;
}
@ -69,7 +69,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<char_ptr_>
struct collection_empty<char_ptr_>
{
static bool fun( const char* s )
{
@ -78,7 +78,7 @@ namespace boost
};
template<>
struct range_empty<const_char_ptr_>
struct collection_empty<const_char_ptr_>
{
static bool fun( const char* s )
{
@ -87,7 +87,7 @@ namespace boost
};
template<>
struct range_empty<wchar_t_ptr_>
struct collection_empty<wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
@ -96,7 +96,7 @@ namespace boost
};
template<>
struct range_empty<const_wchar_t_ptr_>
struct collection_empty<const_wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
@ -111,7 +111,7 @@ namespace boost
inline bool
empty( const C& c )
{
return range_detail::range_empty< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
return range_detail::collection_empty< BOOST_CT_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
}
} // namespace 'boost'

View File

@ -11,37 +11,26 @@
#ifndef BOOST_RANGE_DETAIL_END_HPP
#define BOOST_RANGE_DETAIL_END_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# include <boost/range/detail/vc6/end.hpp>
#else
# include <boost/range/detail/implementation_help.hpp>
# include <boost/range/detail/implementation_help.hpp>
# include <boost/range/result_iterator.hpp>
# include <boost/range/detail/common.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/detail/remove_extent.hpp>
# endif
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_end;
struct collection_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_container_>
struct collection_end<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
fun( C& c )
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<C>::type fun( C& c )
{
return c.end();
};
@ -52,11 +41,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_pair_>
struct collection_end<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
fun( const P& p )
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<P>::type fun( const P& p )
{
return p.second;
}
@ -67,41 +55,33 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<array_>
struct collection_end<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static T* fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( boost_range_array );
return boost::range_detail::array_end( array );
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
{
return t + remove_extent<T>::size;
}
#endif
};
template<>
struct range_end<char_array_>
struct collection_end<char_array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( boost_range_array );
return boost::range_detail::array_end( array );
}
};
template<>
struct range_end<wchar_t_array_>
struct collection_end<wchar_t_array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( boost_range_array );
return boost::range_detail::array_end( array );
}
};
@ -110,7 +90,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<char_ptr_>
struct collection_end<char_ptr_>
{
static char* fun( char* s )
{
@ -119,7 +99,7 @@ namespace boost
};
template<>
struct range_end<const_char_ptr_>
struct collection_end<const_char_ptr_>
{
static const char* fun( const char* s )
{
@ -128,7 +108,7 @@ namespace boost
};
template<>
struct range_end<wchar_t_ptr_>
struct collection_end<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
@ -138,7 +118,7 @@ namespace boost
template<>
struct range_end<const_wchar_t_ptr_>
struct collection_end<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
@ -149,13 +129,13 @@ namespace boost
} // namespace 'range_detail'
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
inline BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type
end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
return range_detail::collection_end< BOOST_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
}
} // namespace 'boost'
# endif // VC6
#endif

View File

@ -51,107 +51,106 @@ namespace boost
}
#endif
template< class Char >
template< typename Char >
inline Char* str_end( Char* s )
{
return const_cast<Char*>( str_end( s, s ) );
}
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], int )
{
return boost_range_array + sz;
return (Char*)str_end( s, s );
}
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], int )
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz], int )
{
return boost_range_array + sz;
}
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
{
return boost_range_array + sz - 1;
return array + sz;
}
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz], int )
{
return boost_range_array + sz - 1;
return array + sz;
}
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz], char_or_wchar_t_array_tag )
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
return array + sz - 1;
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz], char_or_wchar_t_array_tag )
{
return array + sz - 1;
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_end<T,sz>( boost_range_array, tag() );
return array_end<T,sz>( array, tag() );
}
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz] )
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_end<T,sz>( boost_range_array, tag() );
return array_end<T,sz>( array, tag() );
}
/////////////////////////////////////////////////////////////////////
// size() help
/////////////////////////////////////////////////////////////////////
template< class Char >
inline std::size_t str_size( const Char* const& s )
template< typename Char >
inline std::size_t str_size( const Char* s )
{
return str_end( s ) - s;
}
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], int )
template< typename T, std::size_t sz >
inline std::size_t array_size( T BOOST_ARRAY_REF[sz], int )
{
return sz;
}
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz], int )
template< typename T, std::size_t sz >
inline std::size_t array_size( const T BOOST_ARRAY_REF[sz], int )
{
return sz;
}
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
template< typename T, std::size_t sz >
inline std::size_t array_size( T BOOST_ARRAY_REF[sz], char_or_wchar_t_array_tag )
{
return sz - 1;
}
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
template< typename T, std::size_t sz >
inline std::size_t array_size( const T BOOST_ARRAY_REF[sz], char_or_wchar_t_array_tag )
{
return sz - 1;
}
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
template< typename T, std::size_t sz >
inline std::size_t array_size( T (&array)[sz] )
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<const char,T>::value || is_same<const wchar_t,T>::value ||
is_same<char,T>::value || is_same<wchar_t,T>::value,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_size<T,sz>( boost_range_array, tag() );
return array_size<T,sz>( array, tag() );
}
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
template< typename T, std::size_t sz >
inline std::size_t array_size( const T (&array)[sz] )
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_size<T,sz>( boost_range_array, tag() );
return array_size<T,sz>( array, tag() );
}
} // namespace 'range_detail'

View File

@ -12,9 +12,6 @@
#define BOOST_RANGE_DETAIL_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <boost/static_assert.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
@ -25,13 +22,7 @@ namespace boost
namespace range_detail
{
template< typename T >
struct range_iterator_ {
template< typename C >
struct pts
{
typedef int type;
};
};
struct range_iterator_;
template<>
struct range_iterator_<std_container_>
@ -39,7 +30,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type;
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
};
@ -49,31 +40,12 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_iterator_<array_>
{
template< typename T >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_iterator_<char_array_>
{
template< typename T >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
struct range_iterator_<array_>; // give up
template<>
struct range_iterator_<char_ptr_>
@ -114,14 +86,15 @@ namespace boost
typedef const wchar_t* type;
};
};
}
}
template< typename C >
class range_iterator
class iterator_of
{
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef typename range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
typedef BOOST_DEDUCED_TYPENAME range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}

View File

@ -1,97 +0,0 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#if !defined( BOOST_RANGE_DETAIL_MFC_CARRAY_HPP ) && defined( BOOST_RANGE_ENABLE_MCF_CARRAY )
#define BOOST_RANGE_DETAIL_MFC_CARRAY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <afxtempl.h> // for CArray
#include <boost/range/config.hpp>
#include <boost/range/metafunctions.hpp>
namespace boost
{
template< class T, class U >
struct range_iterator< CArray<T,U> >
{
typedef T* type;
};
//
// Why is this needed?!?
//
template< class T, class U >
struct range_iterator< const CArray<T,U> >
{
typedef T* type;
};
template< class T, class U >
struct range_const_iterator< CArray<T,U> >
{
typedef const T* type;
};
template< class T, class U >
struct range_difference< CArray<T,U> >
{
typedef std::ptrdiff_t type;
};
template< class T, class U >
struct range_size< CArray<T,U> >
{
typedef int type;
};
template< class T, class U >
struct range_value< CArray<T,U> >
{
typedef T type;
};
template< class T, class U >
T* boost_range_begin( CArray<T,U>& r )
{
return r.GetData();
}
template< class T, class U >
const T* boost_range_begin( const CArray<T,U>& r )
{
return r.GetData();
}
template< class T, class U >
int boost_range_size( const CArray<T,U>& r )
{
return r.GetSize();
}
template< class T, class U >
T* boost_range_end( CArray<T,U>& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
template< class T, class U >
const T* boost_range_end( const CArray<T,U>& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
// default 'empty()' ok
} // namespace 'boost'
#endif

View File

@ -1,92 +0,0 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#if !defined(BOOST_RANGE_DETAIL_MFC_CSTRING_HPP) && defined(BOOST_RANGE_ENABLE_MFC)
#define BOOST_RANGE_DETAIL_MFC_CSTRING_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <afx.h> // for CString
#include <boost/range/config.hpp>
#include <boost/range/metafunctions.hpp>
namespace boost
{
template<>
struct range_iterator< CString >
{
typedef TCHAR* type;
};
//
// Why is this needed?!?
//
template<>
struct range_iterator< const CString >
{
typedef TCHAR* type;
};
template<>
struct range_const_iterator< CString >
{
typedef const TCHAR* type;
};
template<>
struct range_difference< CString >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_size< CString >
{
typedef int type;
};
template<>
struct range_value< CString >
{
typedef TCHAR type;
};
TCHAR* boost_range_begin( CString& r )
{
return r.GetBuffer(0);
}
const TCHAR* boost_range_begin( const CString& r )
{
return (LPCTSTR)r;
}
int boost_range_size( const CString& r )
{
return r.GetLength();
}
TCHAR* boost_range_end( CString& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
const TCHAR* range_adl_end( const CString& r )
{
return boost_range_begin( r ) + boost_range_size( r );
}
// default 'empty()' ok
} // namespace 'boost'
#endif

View File

@ -1,157 +0,0 @@
// Boost.Range library
//
// Copyright Jonathan Turkanis 2005. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
#define BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
#include <boost/config.hpp> // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std.
#include <cstddef>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost
{
namespace range_detail
{
template< typename Case1 = mpl::true_,
typename Type1 = mpl::void_,
typename Case2 = mpl::true_,
typename Type2 = mpl::void_,
typename Case3 = mpl::true_,
typename Type3 = mpl::void_,
typename Case4 = mpl::true_,
typename Type4 = mpl::void_,
typename Case5 = mpl::true_,
typename Type5 = mpl::void_,
typename Case6 = mpl::true_,
typename Type6 = mpl::void_,
typename Case7 = mpl::true_,
typename Type7 = mpl::void_,
typename Case8 = mpl::true_,
typename Type8 = mpl::void_,
typename Case9 = mpl::true_,
typename Type9 = mpl::void_,
typename Case10 = mpl::true_,
typename Type10 = mpl::void_,
typename Case11 = mpl::true_,
typename Type11 = mpl::void_,
typename Case12 = mpl::true_,
typename Type12 = mpl::void_,
typename Case13 = mpl::true_,
typename Type13 = mpl::void_,
typename Case14 = mpl::true_,
typename Type14 = mpl::void_,
typename Case15 = mpl::true_,
typename Type15 = mpl::void_,
typename Case16 = mpl::true_,
typename Type16 = mpl::void_,
typename Case17 = mpl::true_,
typename Type17 = mpl::void_,
typename Case18 = mpl::true_,
typename Type18 = mpl::void_,
typename Case19 = mpl::true_,
typename Type19 = mpl::void_,
typename Case20 = mpl::true_,
typename Type20 = mpl::void_>
struct select {
typedef typename
mpl::eval_if<
Case1, mpl::identity<Type1>, mpl::eval_if<
Case2, mpl::identity<Type2>, mpl::eval_if<
Case3, mpl::identity<Type3>, mpl::eval_if<
Case4, mpl::identity<Type4>, mpl::eval_if<
Case5, mpl::identity<Type5>, mpl::eval_if<
Case6, mpl::identity<Type6>, mpl::eval_if<
Case7, mpl::identity<Type7>, mpl::eval_if<
Case8, mpl::identity<Type8>, mpl::eval_if<
Case9, mpl::identity<Type9>, mpl::if_<
Case10, Type10, mpl::void_ > > > > > > > > >
>::type result1;
typedef typename
mpl::eval_if<
Case11, mpl::identity<Type11>, mpl::eval_if<
Case12, mpl::identity<Type12>, mpl::eval_if<
Case13, mpl::identity<Type13>, mpl::eval_if<
Case14, mpl::identity<Type14>, mpl::eval_if<
Case15, mpl::identity<Type15>, mpl::eval_if<
Case16, mpl::identity<Type16>, mpl::eval_if<
Case17, mpl::identity<Type17>, mpl::eval_if<
Case18, mpl::identity<Type18>, mpl::eval_if<
Case19, mpl::identity<Type19>, mpl::if_<
Case20, Type20, mpl::void_ > > > > > > > > >
> result2;
typedef typename
mpl::eval_if<
is_same<result1, mpl::void_>,
result2,
mpl::identity<result1>
>::type type;
};
template<typename T>
struct remove_extent {
static T* ar;
BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0]));
typedef typename
select<
is_same<T, bool[size]>, bool,
is_same<T, char[size]>, char,
is_same<T, signed char[size]>, signed char,
is_same<T, unsigned char[size]>, unsigned char,
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
is_same<T, wchar_t[size]>, wchar_t,
#endif
is_same<T, short[size]>, short,
is_same<T, unsigned short[size]>, unsigned short,
is_same<T, int[size]>, int,
is_same<T, unsigned int[size]>, unsigned int,
is_same<T, long[size]>, long,
is_same<T, unsigned long[size]>, unsigned long,
is_same<T, float[size]>, float,
is_same<T, double[size]>, double,
is_same<T, long double[size]>, long double
>::type result1;
typedef typename
select<
is_same<T, const bool[size]>, const bool,
is_same<T, const char[size]>, const char,
is_same<T, const signed char[size]>, const signed char,
is_same<T, const unsigned char[size]>, const unsigned char,
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
is_same<T, const wchar_t[size]>, const wchar_t,
#endif
is_same<T, const short[size]>, const short,
is_same<T, const unsigned short[size]>, const unsigned short,
is_same<T, const int[size]>, const int,
is_same<T, const unsigned int[size]>, const unsigned int,
is_same<T, const long[size]>, const long,
is_same<T, const unsigned long[size]>, const unsigned long,
is_same<T, const float[size]>, const float,
is_same<T, const double[size]>, const double,
is_same<T, const long double[size]>, const long double
> result2;
typedef typename
mpl::eval_if<
is_same<result1, mpl::void_>,
result2,
mpl::identity<result1>
>::type type;
};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View File

@ -28,32 +28,32 @@ namespace boost
// string
//////////////////////////////////////////////////////////////////////
yes_type is_string_impl( const char* const );
yes_type is_string_impl( const wchar_t* const );
yes_type is_string_impl( const char* );
yes_type is_string_impl( const wchar_t* );
no_type is_string_impl( ... );
template< std::size_t sz >
yes_type is_char_array_impl( char BOOST_RANGE_ARRAY_REF()[sz] );
yes_type is_char_array_impl( char BOOST_ARRAY_REF[sz] );
template< std::size_t sz >
yes_type is_char_array_impl( const char BOOST_RANGE_ARRAY_REF()[sz] );
yes_type is_char_array_impl( const char BOOST_ARRAY_REF[sz] );
no_type is_char_array_impl( ... );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
yes_type is_wchar_t_array_impl( wchar_t BOOST_ARRAY_REF[sz] );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( const wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
yes_type is_wchar_t_array_impl( const wchar_t BOOST_ARRAY_REFx[sz] );
no_type is_wchar_t_array_impl( ... );
yes_type is_char_ptr_impl( char* const );
yes_type is_char_ptr_impl( char* );
no_type is_char_ptr_impl( ... );
yes_type is_const_char_ptr_impl( const char* const );
yes_type is_const_char_ptr_impl( const char* );
no_type is_const_char_ptr_impl( ... );
yes_type is_wchar_t_ptr_impl( wchar_t* const );
yes_type is_wchar_t_ptr_impl( wchar_t* );
no_type is_wchar_t_ptr_impl( ... );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* const );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* );
no_type is_const_wchar_t_ptr_impl( ... );
//////////////////////////////////////////////////////////////////////

View File

@ -12,35 +12,27 @@
#ifndef BOOST_RANGE_DETAIL_SIZE_HPP
#define BOOST_RANGE_DETAIL_SIZE_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# include <boost/range/detail/vc6/size.hpp>
#else
# include <boost/range/detail/implementation_help.hpp>
# include <boost/range/detail/size_type.hpp>
# include <boost/range/detail/common.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
# include <boost/range/detail/remove_extent.hpp>
# endif
# include <iterator>
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/common.hpp>
#include <iterator>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_size_;
struct collection_size;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<std_container_>
struct collection_size<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
static BOOST_CT_DEDUCED_TYPENAME C::size_type fun( const C& c )
{
return c.size();
};
@ -51,11 +43,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<std_pair_>
struct collection_size<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type
fun( const P& p )
static BOOST_CT_DEDUCED_TYPENAME size_type_of<P>::type fun( const P& p )
{
return std::distance( p.first, p.second );
}
@ -66,40 +57,32 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<array_>
struct collection_size<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return sz;
}
#else
template<typename T>
static std::size_t fun(T& t)
{
return remove_extent<T>::size;
}
#endif
};
template<>
struct range_size_<char_array_>
struct collection_size<char_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_size( boost_range_array );
return boost::range_detail::array_size( array );
}
};
template<>
struct range_size_<wchar_t_array_>
struct collection_size<wchar_t_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_size( boost_range_array );
return boost::range_detail::array_size( array );
}
};
@ -108,7 +91,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<char_ptr_>
struct collection_size<char_ptr_>
{
static std::size_t fun( const char* s )
{
@ -117,7 +100,7 @@ namespace boost
};
template<>
struct range_size_<const_char_ptr_>
struct collection_size<const_char_ptr_>
{
static std::size_t fun( const char* s )
{
@ -126,7 +109,7 @@ namespace boost
};
template<>
struct range_size_<wchar_t_ptr_>
struct collection_size<wchar_t_ptr_>
{
static std::size_t fun( const wchar_t* s )
{
@ -135,7 +118,7 @@ namespace boost
};
template<>
struct range_size_<const_wchar_t_ptr_>
struct collection_size<const_wchar_t_ptr_>
{
static std::size_t fun( const wchar_t* s )
{
@ -147,13 +130,13 @@ namespace boost
template< typename C >
BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type
BOOST_CT_DEDUCED_TYPENAME size_type_of<C>::type
size( const C& c )
{
return range_detail::range_size_< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
return range_detail::collection_size< BOOST_CT_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
}
} // namespace 'boost'
# endif
#endif

View File

@ -30,7 +30,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::size_type type;
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
};
@ -54,16 +54,6 @@ namespace boost
};
};
template<>
struct range_size_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<char_ptr_>
{
@ -102,15 +92,16 @@ namespace boost
{
typedef std::size_t type;
};
};
};
}
template< typename C >
class range_size
class size_type_of
{
typedef typename range_detail::range<C>::type c_type;
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef typename range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
typedef BOOST_DEDUCED_TYPENAME range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}

View File

@ -26,11 +26,11 @@ namespace boost
template< typename T, std::size_t sz >
char&
sizer( const T BOOST_RANGE_ARRAY_REF()[sz] )[sz];
sizer( const T BOOST_ARRAY_REF[sz] )[sz];
template< typename T, std::size_t sz >
char&
sizer( T BOOST_RANGE_ARRAY_REF()[sz] )[sz];
sizer( T BOOST_ARRAY_REF[sz] )[sz];
} // namespace 'boost'

View File

@ -12,7 +12,6 @@
#define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <boost/iterator/iterator_traits.hpp>
//////////////////////////////////////////////////////////////////////////////
@ -32,7 +31,7 @@ namespace boost
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::value_type type;
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
};
};
@ -42,29 +41,12 @@ namespace boost
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value< BOOST_CT_DEDUCED_TYPENAME P::first_type >::type type;
};
};
template<>
struct range_value_type_<array_>
{
template< typename T >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
};
};
template<>
struct range_value_type_<char_array_>
{
template< typename T >
struct pts
{
typedef char type;
};
};
struct range_value_type_<array_>; // give up
template<>
struct range_value_type_<char_ptr_>
@ -109,7 +91,7 @@ namespace boost
}
template< typename C >
class range_value
class value_type_of
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:

View File

@ -1,170 +0,0 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_VC6_END_HPP
#define BOOST_RANGE_DETAIL_VC6_END_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_container_>
{
template< typename C >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
fun( C& c )
{
return c.end();
};
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_pair_>
{
template< typename P >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
fun( const P& p )
{
return p.second;
}
};
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<array_>
{
template< typename T >
struct inner {
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
fun(T& t)
{
return t + remove_extent<T>::size;
}
};
};
template<>
struct range_end<char_array_>
{
template< typename T >
struct inner {
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
fun(T& t)
{
return t + remove_extent<T>::size;
}
};
};
template<>
struct range_end<wchar_t_array_>
{
template< typename T >
struct inner {
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
fun(T& t)
{
return t + remove_extent<T>::size;
}
};
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<char_ptr_>
{
template< typename T >
struct inner {
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
};
template<>
struct range_end<const_char_ptr_>
{
template< typename T >
struct inner {
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
};
template<>
struct range_end<wchar_t_ptr_>
{
template< typename T >
struct inner {
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
};
template<>
struct range_end<const_wchar_t_ptr_>
{
template< typename T >
struct inner {
static const wchar_t* fun( const wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
};
} // namespace 'range_detail'
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
end( C& c )
{
return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -1,166 +0,0 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_VC6_SIZE_HPP
#define BOOST_RANGE_DETAIL_VC6_SIZE_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <iterator>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_size_;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<std_container_>
{
template< typename C >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
{
return c.size();
};
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<std_pair_>
{
template< typename P >
struct inner {
static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type
fun( const P& p )
{
return std::distance( p.first, p.second );
}
};
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<array_>
{
template<typename T>
struct inner {
static std::size_t fun(T& t)
{
return remove_extent<T>::size;
}
};
};
template<>
struct range_size_<char_array_>
{
template<typename T>
struct inner {
static std::size_t fun(T& t)
{
return sizeof(T) / sizeof(T[0]);
}
};
};
template<>
struct range_size_<wchar_t_array_>
{
template<typename T>
struct inner {
static std::size_t fun(T& t)
{
return sizeof(T) / sizeof(T[0]);
}
};
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_size_<char_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const char* s )
{
return boost::range_detail::str_size( s );
}
};
};
template<>
struct range_size_<const_char_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const char* s )
{
return boost::range_detail::str_size( s );
}
};
};
template<>
struct range_size_<wchar_t_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const wchar_t* s )
{
return boost::range_detail::str_size( s );
}
};
};
template<>
struct range_size_<const_wchar_t_ptr_>
{
template<typename T>
struct inner {
static std::size_t fun( const wchar_t* s )
{
return boost::range_detail::str_size( s );
}
};
};
} // namespace 'range_detail'
template< typename C >
BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type
size( const C& c )
{
return range_detail::range_size_<range_detail::range<C>::type>::inner<C>::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -32,7 +32,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_difference
struct difference_type_of
{
typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
};
@ -42,14 +42,14 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_difference< std::pair<Iterator,Iterator> >
struct difference_type_of< std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_difference<Iterator>::type type;
};
template< typename Iterator >
struct range_difference< const std::pair<Iterator,Iterator> >
struct difference_type_of< const std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_difference<Iterator>::type type;
@ -61,13 +61,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_difference< T[sz] >
struct difference_type_of< T[sz] >
{
typedef std::ptrdiff_t type;
};
template< typename T, std::size_t sz >
struct range_difference< const T[sz] >
struct difference_type_of< const T[sz] >
{
typedef std::ptrdiff_t type;
};
@ -77,49 +77,25 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct range_difference< char* >
struct difference_type_of< char* >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< wchar_t* >
struct difference_type_of< wchar_t* >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< const char* >
struct difference_type_of< const char* >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< const wchar_t* >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< char* const >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< wchar_t* const >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< const char* const >
{
typedef std::ptrdiff_t type;
};
template<>
struct range_difference< const wchar_t* const >
struct difference_type_of< const wchar_t* >
{
typedef std::ptrdiff_t type;
};

View File

@ -16,52 +16,47 @@
#endif
#include <boost/range/config.hpp>
//#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//#include <boost/range/detail/empty.hpp>
//#else
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/empty.hpp>
#else
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
namespace boost
{
namespace range_detail
namespace range
{
//////////////////////////////////////////////////////////////////////
// primary template
// default
//////////////////////////////////////////////////////////////////////
template< typename C >
inline bool empty( const C& c )
{
return boost::begin( c ) == boost::end( c );
return begin( c ) == end( c );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline bool empty( const char* const& s )
inline bool empty( const char* s )
{
return s == 0 || s[0] == 0;
}
inline bool empty( const wchar_t* const& s )
inline bool empty( const wchar_t* s )
{
return s == 0 || s[0] == 0;
}
} // namespace 'range_detail'
} // namespace 'range'
template< class T >
inline bool empty( const T& r )
{
return range_detail::empty( r );
}
using range::empty;
} // namepace 'boost'
//#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#endif

View File

@ -26,29 +26,24 @@
#include <boost/range/const_iterator.hpp>
namespace boost
{
namespace range
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// primary template
// default
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
boost_range_end( const C& c )
inline BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type
end( const C& c )
{
return c.end();
}
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
boost_range_end( C& c )
inline BOOST_DEDUCED_TYPENAME iterator_of<C>::type
end( C& c )
{
return c.end();
}
@ -58,13 +53,13 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator boost_range_end( const std::pair<Iterator,Iterator>& p )
inline Iterator end( const std::pair<Iterator,Iterator>& p )
{
return p.second;
}
template< typename Iterator >
inline Iterator boost_range_end( std::pair<Iterator,Iterator>& p )
inline Iterator end( std::pair<Iterator,Iterator>& p )
{
return p.second;
}
@ -74,125 +69,47 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline const T* boost_range_end( const T (&array)[sz] )
inline const T* end( const T (&array)[sz] )
{
return range_detail::array_end<T,sz>( array );
return range_detail::array_end( array );
}
template< typename T, std::size_t sz >
inline T* boost_range_end( T (&array)[sz] )
inline T* end( T (&array)[sz] )
{
return range_detail::array_end<T,sz>( array );
return range_detail::array_end( array );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
#if 1 || BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// CW up to 9.3 and borland have troubles with function ordering
inline char* boost_range_end( char* s )
inline char* end( char* s )
{
return range_detail::str_end( s );
}
inline wchar_t* boost_range_end( wchar_t* s )
inline wchar_t* end( wchar_t* s )
{
return range_detail::str_end( s );
}
inline const char* boost_range_end( const char* s )
inline const char* end( const char* s )
{
return range_detail::str_end( s );
}
inline const wchar_t* boost_range_end( const wchar_t* s )
{
return range_detail::str_end( s );
}
#else
inline char* boost_range_end( char*& s )
inline const wchar_t* end( const wchar_t* s )
{
return range_detail::str_end( s );
}
} // namespace 'range'
inline wchar_t* boost_range_end( wchar_t*& s )
{
return range_detail::str_end( s );
}
inline const char* boost_range_end( const char*& s )
{
return range_detail::str_end( s );
}
inline const wchar_t* boost_range_end( const wchar_t*& s )
{
return range_detail::str_end( s );
}
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
} // namespace 'range_detail'
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_end( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type end( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return boost_range_end( r );
}
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB and CW are not able to overload pointer when class overloads are also available.
template<>
inline range_const_iterator<const char*>::type end<const char*>( const char*& r )
{
return range_detail::str_end( r );
}
template<>
inline range_const_iterator<const wchar_t*>::type end<const wchar_t*>( const wchar_t*& r )
{
return range_detail::str_end( r );
}
#endif
using range::end;
} // namespace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
const_end( const T& r )
{
return end( r );
}
}
#endif

View File

@ -32,7 +32,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_iterator
struct iterator_of
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
@ -42,13 +42,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_iterator< std::pair<Iterator,Iterator> >
struct iterator_of< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
template< typename Iterator >
struct range_iterator< const std::pair<Iterator,Iterator> >
struct iterator_of< const std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
@ -58,13 +58,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_iterator< T[sz] >
struct iterator_of< T[sz] >
{
typedef T* type;
};
template< typename T, std::size_t sz >
struct range_iterator< const T[sz] >
struct iterator_of< const T[sz] >
{
typedef const T* type;
};
@ -74,49 +74,25 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct range_iterator< char* >
struct iterator_of< char* >
{
typedef char* type;
};
template<>
struct range_iterator< wchar_t* >
struct iterator_of< wchar_t* >
{
typedef wchar_t* type;
};
template<>
struct range_iterator< const char* >
struct iterator_of< const char* >
{
typedef const char* type;
};
template<>
struct range_iterator< const wchar_t* >
{
typedef const wchar_t* type;
};
template<>
struct range_iterator< char* const >
{
typedef char* type;
};
template<>
struct range_iterator< wchar_t* const >
{
typedef wchar_t* type;
};
template<>
struct range_iterator< const char* const >
{
typedef const char* type;
};
template<>
struct range_iterator< const wchar_t* const >
struct iterator_of< const wchar_t* >
{
typedef const wchar_t* type;
};

View File

@ -11,29 +11,14 @@
#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.
#ifndef BOOST_OLD_IOSTREAMS
# if defined(__STL_CONFIG_H) && \
!defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
/**/
# define BOOST_OLD_IOSTREAMS
# endif
#endif // #ifndef BOOST_OLD_IOSTREAMS
#include <boost/detail/workaround.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/assert.hpp>
#include <boost/range/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/tuple/tuple.hpp>
#include <iterator>
#include <algorithm>
#ifndef BOOST_OLD_IOSTREAMS
# include <ostream>
#else
# include <ostream.h>
#endif
#include <ostream>
#include <cstddef>
@ -43,60 +28,7 @@
a rich subset of Container interface.
*/
namespace boost
{
namespace iterator_range_detail
{
//
// The functions adl_begin and adl_end are implemented in a separate
// class for gcc-2.9x
//
template<typename IteratorT>
struct iterator_range_impl {
template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r )
{
using boost::begin;
return IteratorT( begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
using boost::end;
return IteratorT( end( r ) );
}
};
template< class Left, class Right >
inline bool equal( const Left& l, const Right& r )
{
typedef BOOST_DEDUCED_TYPENAME boost::range_size<Left>::type sz_type;
sz_type l_size = size( l ),
r_size = size( r );
if( l_size != r_size )
return false;
return std::equal( begin(l), end(l),
begin(r) );
}
template< class Left, class Right >
inline bool less_than( const Left& l, const Right& r )
{
return std::lexicographical_compare( begin(l),
end(l),
begin(r),
end(r) );
}
struct range_tag { };
struct const_range_tag { };
}
namespace boost {
// iterator range template class -----------------------------------------//
@ -120,28 +52,17 @@ namespace boost
template<typename IteratorT>
class iterator_range
{
protected: // Used by sub_range
//! implementation class
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
public:
//! this type
typedef iterator_range<IteratorT> type;
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
//! Encapsulated value type
typedef BOOST_DEDUCED_TYPENAME
typedef BOOST_DEDUCED_TYPENAME boost::
iterator_value<IteratorT>::type value_type;
//! Difference type
typedef BOOST_DEDUCED_TYPENAME
typedef BOOST_DEDUCED_TYPENAME boost::
iterator_difference<IteratorT>::type difference_type;
//! Size type
typedef std::size_t size_type; // note: must be unsigned
//! This type
typedef iterator_range<IteratorT> this_type;
//! const_iterator type
/*!
@ -152,309 +73,161 @@ namespace boost
//! iterator type
typedef IteratorT iterator;
iterator_range() : m_Begin( iterator() ), m_End( iterator() ),
singular( true )
{ }
/*
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
iterator_range( this_type r ) :
: m_Begin(r.begin()), m_End(r.end())
{ }
this_type& operator=( this_type r )
{
m_Begin = r.begin();
m_End = r.end();
return *this;
}
#endif
*/
//! Default constructor
iterator_range() {}
//! Constructor from a pair of iterators
template< class Iterator >
iterator_range( Iterator Begin, Iterator End ) :
m_Begin(Begin), m_End(End), singular(false) {}
iterator_range( iterator Begin, iterator End ) :
m_Begin(Begin), m_End(End) {}
//! Constructor from a Range
template< class Range >
iterator_range( const Range& r ) :
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ),
singular(false) {}
m_Begin( boost::begin( r ) ), m_End( boost::end( r ) ) {}
//! Constructor from a Range
template< class Range >
iterator_range( Range& r ) :
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ),
singular(false) {}
m_Begin( boost::begin( r ) ), m_End( boost::end( r ) ) {}
//! Constructor from a Range
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 ) ),
singular(false) {}
//! Copy constructor
iterator_range( const iterator_range& Other ) :
m_Begin(Other.begin()), m_End(Other.end()) {}
//! Constructor from a Range
template< class Range >
iterator_range( Range& r, iterator_range_detail::range_tag ) :
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) ),
singular(false) {}
//! Templated copy constructor
/*!
This constructor is provided to allow conversion between
const and mutable iterator instances of this class template
*/
template< typename OtherItT >
iterator_range( const iterator_range<OtherItT>& Other ) :
m_Begin(Other.begin()), m_End(Other.end()) {}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
this_type& operator=( const this_type& r )
//! Assignment operator
iterator_range& operator=( const iterator_range& Other )
{
m_Begin = r.begin();
m_End = r.end();
//
// remark: this need not necessarily be true, but it does no harm
//
singular = r.singular;
return *this;
}
#endif
template< class Iterator >
iterator_range& operator=( const iterator_range<Iterator>& r )
{
m_Begin = r.begin();
m_End = r.end();
//
// remark: this need not necessarily be true, but it does no harm
//
singular = r.empty();
return *this;
}
template< class ForwardRange >
iterator_range& operator=( ForwardRange& r )
{
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
singular = false;
m_Begin=Other.begin(); m_End=Other.end();
return *this;
}
template< class ForwardRange >
iterator_range& operator=( const ForwardRange& r )
//! Assignment operator ( templated version )
template< typename OtherItT >
iterator_range& operator=( const iterator_range<OtherItT>& Other )
{
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
singular = false;
m_Begin=Other.begin(); m_End=Other.end();
return *this;
}
//! Comparison operator ( equal )
/*!
Compare operands for equality
*/
template< typename OtherItT >
bool operator==( const iterator_range<OtherItT>& Other ) const
{
return ! (*this != Other);
}
//! Comparison operator ( not-equal )
/*!
Compare operands for non-equality
*/
template< typename OtherItT >
bool operator!=( const iterator_range<OtherItT>& Other ) const
{
return m_Begin!=Other.begin() || m_End!=Other.end();
}
//! begin access
/*!
Retrieve the begin iterator
*/
IteratorT begin() const
{
return m_Begin;
}
//! end access
/*!
Retrieve the end iterator
*/
IteratorT end() const
{
return m_End;
}
//! Size of the range
/*!
Retrieve the size of the range
*/
size_type size() const
{
if( singular )
return 0;
return std::distance( m_Begin, m_End );
}
bool empty() const
{
if( singular )
return true;
return m_Begin == m_End;
}
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
operator bool() const
//! Swap
/*!
Swap two ranges
*/
void swap( iterator_range& Other )
{
return !empty();
}
#else
std::swap( m_Begin, Other.m_Begin );
std::swap( m_End, Other.m_End );
}
//! Safe bool conversion
/*!
Check whenever the range is empty.
Allows to use construction like this:
\code
iterator_range r;
if (!r)
{
...
}
\endcode
*/
typedef iterator (iterator_range::*unspecified_bool_type) () const;
operator unspecified_bool_type() const
{
return empty() ? 0: &iterator_range::end;
}
#endif
bool equal( const iterator_range& r ) const
{
return singular == r.singular && m_Begin == r.m_Begin && m_End == r.m_End;
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
bool operator==( const iterator_range& r ) const
{
return iterator_range_detail::equal( *this, r );
}
bool operator!=( const iterator_range& r ) const
{
return !operator==(r);
}
bool operator<( const iterator_range& r ) const
{
return iterator_range_detail::less_than( *this, r );
}
#endif
public: // convenience
value_type& front() const
{
BOOST_ASSERT( !empty() );
return *m_Begin;
}
value_type& back() const
{
BOOST_ASSERT( !empty() );
IteratorT last( m_End );
return *--last;
}
value_type& operator[]( size_type sz ) const
{
//BOOST_STATIC_ASSERT( is_random_access );
BOOST_ASSERT( sz < size() );
return m_Begin[sz];
}
/*
inline operator t_type() const
{
return make_tuple( m_Begin, m_End );
}*/
private:
// begin and end iterators
IteratorT m_Begin;
IteratorT m_End;
bool singular;
};
// iterator range free-standing operators ---------------------------//
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#else
template< class Iterator >
inline bool empty( const iterator_range<Iterator>& r )
{
//
// this will preserve the well-defined empty() even
// though 'r' is singular.
//
return r.empty();
}
#endif
#ifndef BOOST_OLD_IOSTREAMS
//! iterator_range output operator
/*!
Output the range to an ostream. Elements are outputed
in a sequence without separators.
*/
template< typename IteratorT, typename Elem, typename Traits >
inline std::basic_ostream<Elem,Traits>& operator<<(
std::basic_ostream<Elem, Traits>& Os,
const iterator_range<IteratorT>& r )
std::basic_ostream<Elem,Traits>& operator<<(
std::basic_ostream<Elem, Traits>& Os,
const iterator_range<IteratorT>& r )
{
std::copy( r.begin(), r.end(), std::ostream_iterator<Elem>(Os));
std::copy( begin(r), end(r), std::ostream_iterator<Elem>(Os));
return Os;
}
#else
//! iterator_range output operator
/*!
Output the range to an ostream. Elements are outputed
in a sequence without separators.
*/
template< typename IteratorT >
inline std::ostream& operator<<(
std::ostream& Os,
const iterator_range<IteratorT>& r )
{
std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os));
return Os;
}
#endif
/////////////////////////////////////////////////////////////////////
// comparison operators
/////////////////////////////////////////////////////////////////////
template< class IteratorT, class ForwardRange >
inline bool operator==( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator!=( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator<( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::less_than( l, r );
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#else
template< class Iterator1T, class Iterator2T >
inline bool operator==( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator==( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::equal( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator!=( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator!=( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator<( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::less_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator<( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::less_than( l, r );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
// iterator range utilities -----------------------------------------//
//! iterator_range construct helper
@ -471,97 +244,28 @@ namespace boost
{
return iterator_range<IteratorT>( Begin, End );
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
make_iterator_range( Range& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
( begin( r ), end( r ) );
}
#else
//! iterator_range construct helper
/*!
Construct an \c iterator_range from a \c Range containing the begin
and end iterators.
*/
template< class ForwardRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
make_iterator_range( ForwardRange& r )
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME iterator_of<Range>::type >
make_iterator_range( Range& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
( r, iterator_range_detail::range_tag() );
return iterator_range< BOOST_DEDUCED_TYPENAME iterator_of<Range>::type >
( r );
}
template< class ForwardRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type >
make_iterator_range( const ForwardRange& r )
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME const_iterator_of<Range>::type >
make_iterator_range( const Range& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type >
( r, iterator_range_detail::const_range_tag() );
return iterator_range< BOOST_DEDUCED_TYPENAME const_iterator_of<Range>::type >
( r );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace iterator_range_detail
{
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
make_range_impl( Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
if( advance_begin == 0 && advance_end == 0 )
return make_iterator_range( r );
BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type
new_begin = begin( r ),
new_end = end( r );
std::advance( new_begin, advance_begin );
std::advance( new_end, advance_end );
return make_iterator_range( new_begin, new_end );
}
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
make_iterator_range( Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
}
#else
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
make_iterator_range( Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
}
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<Range>::type >
make_iterator_range( const Range& r,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
{
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//! copy a range into a sequence
/*!
Construct a new sequence of the specified type from the elements
@ -576,8 +280,24 @@ namespace boost
return SeqT( begin( r ), end( r ) );
}
//! transform a range into a sequence
/*!
Create a new sequence from the elements in the range, transformed
by a function
\param Range An input range
\param Func Transformation function
\return New sequence
*/
template< typename SeqT, typename Range, typename FuncT >
inline SeqT transform_range( const Range& r, FuncT Func )
{
SeqT Seq;
std::transform( begin( r ), end( r ), std::back_inserter(Seq), Func );
return Seq;
}
} // namespace 'boost'
#undef BOOST_OLD_IOSTREAMS
#endif

View File

@ -16,51 +16,26 @@
#endif
#include <boost/range/end.hpp>
#include <boost/range/reverse_result_iterator.hpp>
#include <boost/range/reverse_iterator.hpp>
#include <boost/range/const_reverse_iterator.hpp>
namespace boost
{
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type
inline BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type
rbegin( C& c )
{
return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type( end( c ) );
}
#else
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rbegin( C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
iter_type;
return iter_type( end( c ) );
return BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type( end( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
inline BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type
rbegin( const C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
iter_type;
return iter_type( end( c ) );
return BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type( end( c ) );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<T>::type
const_rbegin( const T& r )
{
return rbegin( r );
}
} // namespace 'boost'
#endif

View File

@ -16,49 +16,24 @@
#endif
#include <boost/range/begin.hpp>
#include <boost/range/reverse_result_iterator.hpp>
#include <boost/range/reverse_iterator.hpp>
#include <boost/range/const_reverse_iterator.hpp>
namespace boost
{
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type
inline BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type
rend( C& c )
{
return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type( begin( c ) );
}
#else
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rend( C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
iter_type;
return iter_type( begin( c ) );
return BOOST_DEDUCED_TYPENAME reverse_iterator_of<C>::type( begin( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
inline BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type
rend( const C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
iter_type;
return iter_type( begin( c ) );
}
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<T>::type
const_rend( const T& r )
{
return rend( r );
return BOOST_DEDUCED_TYPENAME const_reverse_iterator_of<C>::type( begin( c ) );
}
} // namespace 'boost'

View File

@ -28,12 +28,12 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_result_iterator
struct result_iterator_of
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
typedef BOOST_CT_DEDUCED_TYPENAME
mpl::if_< BOOST_DEDUCED_TYPENAME is_const<C>::type,
BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type,
BOOST_DEDUCED_TYPENAME range_iterator<C>::type >::type type;
BOOST_DEDUCED_TYPENAME const_iterator_of<C>::type,
BOOST_DEDUCED_TYPENAME iterator_of<C>::type >::type type;
};
} // namespace boost

View File

@ -27,10 +27,10 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_reverse_iterator
struct reverse_iterator_of
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME range_iterator<C>::type > type;
BOOST_DEDUCED_TYPENAME iterator_of<C>::type > type;
};

View File

@ -26,12 +26,14 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_reverse_result_iterator
struct reverse_result_iterator_of
{
typedef reverse_iterator<
BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type > type;
BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type > type;
};
} // namespace boost
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View File

@ -22,25 +22,21 @@
#else
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/size_type.hpp>
#include <cstddef>
#include <iterator>
#include <utility>
namespace boost
namespace boost {
namespace range
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// primary template
// default
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME C::size_type
boost_range_size( const C& c )
inline BOOST_CT_DEDUCED_TYPENAME C::size_type
size( const C& c )
{
return c.size();
}
@ -50,7 +46,7 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline std::size_t boost_range_size( const std::pair<Iterator,Iterator>& p )
inline std::size_t size( const std::pair<Iterator,Iterator>& p )
{
return std::distance( p.first, p.second );
}
@ -60,61 +56,34 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline std::size_t boost_range_size( const T (&array)[sz] )
inline std::size_t size( const T (&array)[sz] )
{
return range_detail::array_size<T,sz>( array );
return range_detail::array_size( array );
}
template< typename T, std::size_t sz >
inline std::size_t boost_range_size( T (&array)[sz] )
inline std::size_t size( T (&array)[sz] )
{
return boost::range_detail::array_size<T,sz>( array );
return range_detail::array_size( array );
}
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
inline std::size_t boost_range_size( const char* const& s )
inline std::size_t size( const char* s )
{
return boost::range_detail::str_size( s );
return range_detail::str_size( s );
}
inline std::size_t boost_range_size( const wchar_t* const& s )
inline std::size_t size( const wchar_t* s )
{
return boost::range_detail::str_size( s );
return range_detail::str_size( s );
}
} // namespace 'range'
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
} // namespace 'range_detail'
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_size<T>::type size( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
using namespace range_detail;
#endif
return boost_range_size( r );
}
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// BCB and CW are not able to overload pointer when class overloads are also available.
inline range_size<const char*>::type size( const char* r ) {
return range_detail::str_size( r );
}
inline range_size<char*>::type size( char* r ) {
return range_detail::str_size( r );
}
inline range_size<const wchar_t*>::type size( const wchar_t* r ) {
return range_detail::str_size( r );
}
inline range_size<wchar_t*>::type size( wchar_t* r ) {
return range_detail::str_size( r );
}
#endif
using range::size;
} // namespace 'boost'

View File

@ -31,7 +31,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_size
struct size_type_of
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
@ -41,13 +41,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_size< std::pair<Iterator,Iterator> >
struct size_type_of< std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
template< typename Iterator >
struct range_size< const std::pair<Iterator,Iterator> >
struct size_type_of< const std::pair<Iterator,Iterator> >
{
typedef std::size_t type;
};
@ -57,13 +57,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_size< T[sz] >
struct size_type_of< T[sz] >
{
typedef std::size_t type;
};
template< typename T, std::size_t sz >
struct range_size< const T[sz] >
struct size_type_of< const T[sz] >
{
typedef std::size_t type;
};
@ -73,49 +73,25 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct range_size< char* >
struct size_type_of< char* >
{
typedef std::size_t type;
};
template<>
struct range_size< wchar_t* >
struct size_type_of< wchar_t* >
{
typedef std::size_t type;
};
template<>
struct range_size< const char* >
struct size_type_of< const char* >
{
typedef std::size_t type;
};
template<>
struct range_size< const wchar_t* >
{
typedef std::size_t type;
};
template<>
struct range_size< char* const >
{
typedef std::size_t type;
};
template<>
struct range_size< wchar_t* const >
{
typedef std::size_t type;
};
template<>
struct range_size< const char* const >
{
typedef std::size_t type;
};
template<>
struct range_size< const wchar_t* const >
struct size_type_of< const wchar_t* >
{
typedef std::size_t type;
};

View File

@ -13,65 +13,36 @@
#include <boost/range/config.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/result_iterator.hpp>
#include <boost/range/reverse_result_iterator.hpp>
#include <boost/range/size_type.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/assert.hpp>
//#include <boost/range/rbegin.hpp>
//#include <boost/range/rend.hpp>
namespace boost
{
template< class ForwardRange >
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type >
template< class Range >
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type >
{
typedef BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type iterator_t;
typedef BOOST_DEDUCED_TYPENAME result_iterator_of<Range>::type iterator_t;
typedef iterator_range< iterator_t > base;
typedef BOOST_DEDUCED_TYPENAME base::impl impl;
public:
typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type value_type;
typedef BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type iterator;
typedef BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type const_iterator;
typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
using base::iterator;
using base::const_iterator;
using base::value_type;
typedef BOOST_DEDUCED_TYPENAME difference_type_of<Range>::type difference_type;
typedef BOOST_DEDUCED_TYPENAME size_type_of<Range>::type size_type;
public:
sub_range() : base()
{ }
/*
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
typedef sub_range<ForwardRange> this_type;
sub_range( this_type r ) :
: base( r )
{ }
this_type& operator=( this_type r )
{
base::operator=( r );
return *this;
}
#endif
*/
template< class ForwardRange2 >
sub_range( ForwardRange2& r ) :
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
base( impl::adl_begin( r ), impl::adl_end( r ) )
#else
base( r )
#endif
template< class Range2 >
sub_range( Range2& r ) : base( r )
{ }
template< class ForwardRange2 >
sub_range( const ForwardRange2& r ) :
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
base( impl::adl_begin( r ), impl::adl_end( r ) )
#else
base( r )
#endif
template< class Range2 >
sub_range( const Range2& r ) : base( r )
{ }
template< class Iter >
@ -79,84 +50,77 @@ namespace boost
base( first, last )
{ }
template< class ForwardRange2 >
sub_range& operator=( ForwardRange2& r )
template< class Range2 >
sub_range& operator=( Range2& r )
{
base::operator=( r );
return *this;
}
template< class ForwardRange2 >
sub_range& operator=( const ForwardRange2& r )
template< class Range2 >
sub_range& operator=( const Range2& r )
{
base::operator=( r );
return *this;
}
public:
iterator begin() { return base::begin(); }
const_iterator begin() const { return base::begin(); }
iterator end() { return base::end(); }
const_iterator end() const { return base::end(); }
size_type size() const { return base::size(); }
public: // convenience
value_type& front()
size_type size() const
{
return base::front();
}
const value_type& front() const
{
return base::front();
}
value_type& back()
{
return base::back();
}
const value_type& back() const
{
return base::back();
}
value_type& operator[]( size_type sz )
{
return base::operator[](sz);
}
const value_type& operator[]( size_type sz ) const
{
return base::operator[](sz);
//
// performance discontinuity problem!!
//
return base::size();
}
};
template< class ForwardRange, class ForwardRange2 >
inline bool operator==( const sub_range<ForwardRange>& l,
const sub_range<ForwardRange2>& r )
/*
template< class Range >
class reverse_sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME reverse_result_iterator_of<Range>::type >
{
return iterator_range_detail::equal( l, r );
}
typedef BOOST_DEDUCED_TYPENAME reverse_result_iterator_of<Range>::type
iterator_t;
typedef iterator_range<iterator_t> base;
public:
using base::iterator;
using base::const_iterator;
using base::value_type;
using base::difference_type;
using base::size_type;
public:
template< class Range2 >
reverse_sub_range( Range2& r ) : base( rbegin( r ), rend( r ) )
{ }
template< class Range2 >
reverse_sub_range( const Range2& r ) : base( rbegin( r ), rend( r ) )
{ }
template< class ForwardRange, class ForwardRange2 >
inline bool operator!=( const sub_range<ForwardRange>& l,
const sub_range<ForwardRange2>& r )
{
return !iterator_range_detail::equal( l, r );
}
template< class ForwardRange, class ForwardRange2 >
inline bool operator<( const sub_range<ForwardRange>& l,
const sub_range<ForwardRange2>& r )
{
return iterator_range_detail::less_than( l, r );
}
template< class Iter >
reverse_sub_range( Iter first, Iter last ) :
base( iterator_t( last ), iterator_t( first ) )
{ }
template< class Range2 >
sub_range& operator=( Range2& r )
{
base::operator=( r );
return *this;
}
template< class Range2 >
sub_range& operator=( const Range2& r )
{
base::operator=( r );
return *this;
}
};
*/
} // namespace 'boost'
#endif

View File

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

View File

@ -33,7 +33,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_value
struct value_type_of
{
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
};
@ -43,7 +43,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_value< std::pair<Iterator,Iterator> >
struct value_type_of< std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_value<Iterator>::type type;
@ -51,7 +51,7 @@ namespace boost
template< typename Iterator >
struct range_value< const std::pair<Iterator,Iterator> >
struct value_type_of< const std::pair<Iterator,Iterator> >
{
typedef BOOST_DEDUCED_TYPENAME
iterator_value<Iterator>::type type;
@ -62,13 +62,13 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_value< T[sz] >
struct value_type_of< T[sz] >
{
typedef T type;
};
template< typename T, std::size_t sz >
struct range_value< const T[sz] >
struct value_type_of< const T[sz] >
{
typedef const T type;
};
@ -78,49 +78,25 @@ namespace boost
//////////////////////////////////////////////////////////////////////////
template<>
struct range_value< char* >
struct value_type_of< char* >
{
typedef char type;
};
template<>
struct range_value< wchar_t* >
struct value_type_of< wchar_t* >
{
typedef wchar_t type;
};
template<>
struct range_value< const char* >
struct value_type_of< const char* >
{
typedef const char type;
};
template<>
struct range_value< const wchar_t* >
{
typedef const wchar_t type;
};
template<>
struct range_value< char* const >
{
typedef char type;
};
template<>
struct range_value< wchar_t* const >
{
typedef wchar_t type;
};
template<>
struct range_value< const char* const >
{
typedef const char type;
};
template<>
struct range_value< const wchar_t* const >
struct value_type_of< const wchar_t* >
{
typedef const wchar_t type;
};