Initial work for G-code sender and more intensive usage of Boost

This commit is contained in:
Alessandro Ranellucci 2014-11-26 22:30:25 +01:00
parent 43cbad8867
commit 11dd67ab34
1649 changed files with 1860 additions and 1642 deletions

View file

@ -0,0 +1,198 @@
// Boost.Range library
//
// Copyright Neil Groves 2009.
// 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_ALGORITHM_EQUAL_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED
#include <boost/config.hpp>
#include <boost/range/concepts.hpp>
#include <iterator>
namespace boost
{
namespace range_detail
{
// An implementation of equality comparison that is optimized for iterator
// traversal categories less than RandomAccessTraversal.
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class IteratorCategoryTag1,
class IteratorCategoryTag2 >
inline bool equal_impl( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
IteratorCategoryTag1,
IteratorCategoryTag2 )
{
while (true)
{
// If we have reached the end of the left range then this is
// the end of the loop. They are equal if and only if we have
// simultaneously reached the end of the right range.
if (first1 == last1)
return first2 == last2;
// If we have reached the end of the right range at this line
// it indicates that the right range is shorter than the left
// and hence the result is false.
if (first2 == last2)
return false;
// continue looping if and only if the values are equal
if (*first1 != *first2)
break;
++first1;
++first2;
}
// Reaching this line in the algorithm indicates that a value
// inequality has been detected.
return false;
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class IteratorCategoryTag1,
class IteratorCategoryTag2,
class BinaryPredicate >
inline bool equal_impl( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
BinaryPredicate pred,
IteratorCategoryTag1,
IteratorCategoryTag2 )
{
while (true)
{
// If we have reached the end of the left range then this is
// the end of the loop. They are equal if and only if we have
// simultaneously reached the end of the right range.
if (first1 == last1)
return first2 == last2;
// If we have reached the end of the right range at this line
// it indicates that the right range is shorter than the left
// and hence the result is false.
if (first2 == last2)
return false;
// continue looping if and only if the values are equal
if (!pred(*first1, *first2))
break;
++first1;
++first2;
}
// Reaching this line in the algorithm indicates that a value
// inequality has been detected.
return false;
}
// An implementation of equality comparison that is optimized for
// random access iterators.
template< class RandomAccessTraversalReadableIterator1,
class RandomAccessTraversalReadableIterator2 >
inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
RandomAccessTraversalReadableIterator1 last1,
RandomAccessTraversalReadableIterator2 first2,
RandomAccessTraversalReadableIterator2 last2,
std::random_access_iterator_tag,
std::random_access_iterator_tag )
{
return ((last1 - first1) == (last2 - first2))
&& std::equal(first1, last1, first2);
}
template< class RandomAccessTraversalReadableIterator1,
class RandomAccessTraversalReadableIterator2,
class BinaryPredicate >
inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
RandomAccessTraversalReadableIterator1 last1,
RandomAccessTraversalReadableIterator2 first2,
RandomAccessTraversalReadableIterator2 last2,
BinaryPredicate pred )
{
return ((last1 - first1) == (last2 - first2))
&& std::equal(first1, last1, first2, pred);
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2 >
inline bool equal( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2 )
{
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1;
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2;
return equal_impl(first1, last1, first2, last2, tag1, tag2);
}
template< class SinglePassTraversalReadableIterator1,
class SinglePassTraversalReadableIterator2,
class BinaryPredicate >
inline bool equal( SinglePassTraversalReadableIterator1 first1,
SinglePassTraversalReadableIterator1 last1,
SinglePassTraversalReadableIterator2 first2,
SinglePassTraversalReadableIterator2 last2,
BinaryPredicate pred )
{
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1;
BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2;
return equal_impl(first1, last1, first2, last2, pred, tag1, tag2);
}
} // namespace range_detail
namespace range
{
/// \brief template function equal
///
/// range-based version of the equal std algorithm
///
/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
template< class SinglePassRange1, class SinglePassRange2 >
inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 )
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
return ::boost::range_detail::equal(
::boost::begin(rng1), ::boost::end(rng1),
::boost::begin(rng2), ::boost::end(rng2) );
}
/// \overload
template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
BinaryPredicate pred )
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
return ::boost::range_detail::equal(
::boost::begin(rng1), ::boost::end(rng1),
::boost::begin(rng2), ::boost::end(rng2),
pred);
}
} // namespace range
using ::boost::range::equal;
} // namespace boost
#endif // include guard

View file

@ -0,0 +1,143 @@
// 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_BEGIN_HPP
#define BOOST_RANGE_BEGIN_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/begin.hpp>
#else
#include <boost/range/iterator.hpp>
namespace boost
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// primary template
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
range_begin( C& c )
{
//
// If you get a compile-error here, it is most likely because
// you have not implemented range_begin() properly in
// the namespace of C
//
return c.begin();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
{
return p.first;
}
template< typename Iterator >
inline Iterator range_begin( std::pair<Iterator,Iterator>& p )
{
return p.first;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
//
// May this be discarded? Or is it needed for bad compilers?
//
template< typename T, std::size_t sz >
inline const T* range_begin( const T (&a)[sz] )
{
return a;
}
template< typename T, std::size_t sz >
inline T* range_begin( T (&a)[sz] )
{
return a;
}
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
} // namespace 'range_detail'
#endif
// Use a ADL namespace barrier to avoid ambiguity with other unqualified
// calls. This is particularly important with C++0x encouraging
// unqualified calls to begin/end.
namespace range_adl_barrier
{
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 range_begin( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_begin( r );
}
} // namespace range_adl_barrier
} // namespace boost
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
namespace range_adl_barrier
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_begin( const T& r )
{
return boost::range_adl_barrier::begin( r );
}
} // namespace range_adl_barrier
using namespace range_adl_barrier;
} // namespace boost
#endif

View file

@ -0,0 +1,366 @@
// Boost.Range library concept checks
//
// Copyright Neil Groves 2009. Use, modification and distribution
// are 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)
//
// Copyright Daniel Walker 2006. Use, modification and distribution
// are 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_CONCEPTS_HPP
#define BOOST_RANGE_CONCEPTS_HPP
#include <boost/concept_check.hpp>
#include <boost/iterator/iterator_concepts.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/detail/misc_concept.hpp>
/*!
* \file
* \brief Concept checks for the Boost Range library.
*
* The structures in this file may be used in conjunction with the
* Boost Concept Check library to insure that the type of a function
* parameter is compatible with a range concept. If not, a meaningful
* compile time error is generated. Checks are provided for the range
* concepts related to iterator traversal categories. For example, the
* following line checks that the type T models the ForwardRange
* concept.
*
* \code
* BOOST_CONCEPT_ASSERT((ForwardRangeConcept<T>));
* \endcode
*
* A different concept check is required to ensure writeable value
* access. For example to check for a ForwardRange that can be written
* to, the following code is required.
*
* \code
* BOOST_CONCEPT_ASSERT((WriteableForwardRangeConcept<T>));
* \endcode
*
* \see http://www.boost.org/libs/range/doc/range.html for details
* about range concepts.
* \see http://www.boost.org/libs/iterator/doc/iterator_concepts.html
* for details about iterator concepts.
* \see http://www.boost.org/libs/concept_check/concept_check.htm for
* details about concept checks.
*/
namespace boost {
namespace range_detail {
#ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
// List broken compiler versions here:
#ifdef __GNUC__
// GNUC 4.2 has strange issues correctly detecting compliance with the Concepts
// hence the least disruptive approach is to turn-off the concept checking for
// this version of the compiler.
#if __GNUC__ == 4 && __GNUC_MINOR__ == 2
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
#endif
#endif
#ifdef __BORLANDC__
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
#endif
#ifdef __PATHCC__
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
#endif
// Default to using the concept asserts unless we have defined it off
// during the search for black listed compilers.
#ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
#define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 1
#endif
#endif
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
#define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x )
#else
#define BOOST_RANGE_CONCEPT_ASSERT( x )
#endif
// Rationale for the inclusion of redefined iterator concept
// classes:
//
// The Range algorithms often do not require that the iterators are
// Assignable or default constructable, but the correct standard
// conformant iterators do require the iterators to be a model of the
// Assignable concept.
// Iterators that contains a functor that is not assignable therefore
// are not correct models of the standard iterator concepts,
// despite being adequate for most algorithms. An example of this
// use case is the combination of the boost::adaptors::filtered
// class with a boost::lambda::bind generated functor.
// Ultimately modeling the range concepts using composition
// with the Boost.Iterator concepts would render the library
// incompatible with many common Boost.Lambda expressions.
template<class Iterator>
struct IncrementableIteratorConcept : CopyConstructible<Iterator>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
typedef BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator>::type traversal_category;
BOOST_RANGE_CONCEPT_ASSERT((
Convertible<
traversal_category,
incrementable_traversal_tag
>));
BOOST_CONCEPT_USAGE(IncrementableIteratorConcept)
{
++i;
(void)i++;
}
private:
Iterator i;
#endif
};
template<class Iterator>
struct SinglePassIteratorConcept
: IncrementableIteratorConcept<Iterator>
, EqualityComparable<Iterator>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
BOOST_RANGE_CONCEPT_ASSERT((
Convertible<
BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category,
single_pass_traversal_tag
>));
BOOST_CONCEPT_USAGE(SinglePassIteratorConcept)
{
Iterator i2(++i);
boost::ignore_unused_variable_warning(i2);
// deliberately we are loose with the postfix version for the single pass
// iterator due to the commonly poor adherence to the specification means that
// many algorithms would be unusable, whereas actually without the check they
// work
(void)(i++);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r1(*i);
boost::ignore_unused_variable_warning(r1);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r2(*(++i));
boost::ignore_unused_variable_warning(r2);
}
private:
Iterator i;
#endif
};
template<class Iterator>
struct ForwardIteratorConcept
: SinglePassIteratorConcept<Iterator>
, DefaultConstructible<Iterator>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::difference_type difference_type;
BOOST_MPL_ASSERT((is_integral<difference_type>));
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
BOOST_RANGE_CONCEPT_ASSERT((
Convertible<
BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category,
forward_traversal_tag
>));
BOOST_CONCEPT_USAGE(ForwardIteratorConcept)
{
// See the above note in the SinglePassIteratorConcept about the handling of the
// postfix increment. Since with forward and better iterators there is no need
// for a proxy, we can sensibly require that the dereference result
// is convertible to reference.
Iterator i2(i++);
boost::ignore_unused_variable_warning(i2);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r(*(i++));
boost::ignore_unused_variable_warning(r);
}
private:
Iterator i;
#endif
};
template<class Iterator>
struct BidirectionalIteratorConcept
: ForwardIteratorConcept<Iterator>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
BOOST_RANGE_CONCEPT_ASSERT((
Convertible<
BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept::traversal_category,
bidirectional_traversal_tag
>));
BOOST_CONCEPT_USAGE(BidirectionalIteratorConcept)
{
--i;
(void)i--;
}
private:
Iterator i;
#endif
};
template<class Iterator>
struct RandomAccessIteratorConcept
: BidirectionalIteratorConcept<Iterator>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
BOOST_RANGE_CONCEPT_ASSERT((
Convertible<
BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::traversal_category,
random_access_traversal_tag
>));
BOOST_CONCEPT_USAGE(RandomAccessIteratorConcept)
{
i += n;
i = i + n;
i = n + i;
i -= n;
i = i - n;
n = i - j;
}
private:
BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n;
Iterator i;
Iterator j;
#endif
};
} // namespace range_detail
//! Check if a type T models the SinglePassRange range concept.
template<class T>
struct SinglePassRangeConcept
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
typedef BOOST_DEDUCED_TYPENAME range_iterator<T const>::type const_iterator;
typedef BOOST_DEDUCED_TYPENAME range_iterator<T>::type iterator;
BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<iterator>));
BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<const_iterator>));
BOOST_CONCEPT_USAGE(SinglePassRangeConcept)
{
// This has been modified from assigning to this->i
// (where i was a member variable) to improve
// compatibility with Boost.Lambda
iterator i1 = boost::begin(*m_range);
iterator i2 = boost::end(*m_range);
ignore_unused_variable_warning(i1);
ignore_unused_variable_warning(i2);
const_constraints(*m_range);
}
private:
void const_constraints(const T& const_range)
{
const_iterator ci1 = boost::begin(const_range);
const_iterator ci2 = boost::end(const_range);
ignore_unused_variable_warning(ci1);
ignore_unused_variable_warning(ci2);
}
// Rationale:
// The type of m_range is T* rather than T because it allows
// T to be an abstract class. The other obvious alternative of
// T& produces a warning on some compilers.
T* m_range;
#endif
};
//! Check if a type T models the ForwardRange range concept.
template<class T>
struct ForwardRangeConcept : SinglePassRangeConcept<T>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::iterator>));
BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::const_iterator>));
#endif
};
template<class Range>
struct WriteableRangeConcept
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
typedef BOOST_DEDUCED_TYPENAME range_iterator<Range>::type iterator;
BOOST_CONCEPT_USAGE(WriteableRangeConcept)
{
*i = v;
}
private:
iterator i;
BOOST_DEDUCED_TYPENAME range_value<Range>::type v;
#endif
};
//! Check if a type T models the WriteableForwardRange range concept.
template<class T>
struct WriteableForwardRangeConcept
: ForwardRangeConcept<T>
, WriteableRangeConcept<T>
{
};
//! Check if a type T models the BidirectionalRange range concept.
template<class T>
struct BidirectionalRangeConcept : ForwardRangeConcept<T>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
BOOST_RANGE_CONCEPT_ASSERT((range_detail::BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::iterator>));
BOOST_RANGE_CONCEPT_ASSERT((range_detail::BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::const_iterator>));
#endif
};
//! Check if a type T models the WriteableBidirectionalRange range concept.
template<class T>
struct WriteableBidirectionalRangeConcept
: BidirectionalRangeConcept<T>
, WriteableRangeConcept<T>
{
};
//! Check if a type T models the RandomAccessRange range concept.
template<class T>
struct RandomAccessRangeConcept : BidirectionalRangeConcept<T>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
BOOST_RANGE_CONCEPT_ASSERT((range_detail::RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::iterator>));
BOOST_RANGE_CONCEPT_ASSERT((range_detail::RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::const_iterator>));
#endif
};
//! Check if a type T models the WriteableRandomAccessRange range concept.
template<class T>
struct WriteableRandomAccessRangeConcept
: RandomAccessRangeConcept<T>
, WriteableRangeConcept<T>
{
};
} // namespace boost
#endif // BOOST_RANGE_CONCEPTS_HPP

View file

@ -0,0 +1,54 @@
// 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_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
#error "macro already defined!"
#endif
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# define BOOST_RANGE_DEDUCED_TYPENAME 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
#endif
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
#error "macro already defined!"
#endif
#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
#define BOOST_RANGE_NO_ARRAY_SUPPORT 1
#endif
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
#define BOOST_RANGE_ARRAY_REF() (boost_range_array)
#define BOOST_RANGE_NO_STATIC_ASSERT
#else
#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
#endif
#endif

View file

@ -0,0 +1,67 @@
// 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_CONST_ITERATOR_HPP
#define BOOST_RANGE_CONST_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/const_iterator.hpp>
#else
#include <boost/range/detail/extract_optional_type.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
namespace range_detail {
BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( const_iterator )
}
template< typename C >
struct range_const_iterator : range_detail::extract_const_iterator<C>
{};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_const_iterator< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_const_iterator< T[sz] >
{
typedef const T* type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View file

@ -0,0 +1,94 @@
// 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_BEGIN_HPP
#define BOOST_RANGE_DETAIL_BEGIN_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/detail/common.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/value_type.hpp>
#endif
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_begin;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
{
return c.begin();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
{
return p.first;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
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] )
{
return boost_range_array;
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
{
return t;
}
#endif
};
} // namespace 'range_detail'
namespace range_adl_barrier
{
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
}
} // namespace 'boost'
#endif

View file

@ -0,0 +1,117 @@
// 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_COMMON_HPP
#define BOOST_RANGE_DETAIL_COMMON_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <cstddef>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
// 1 = std containers
// 2 = std::pair
// 3 = const std::pair
// 4 = array
// 5 = const array
// 6 = char array
// 7 = wchar_t array
// 8 = char*
// 9 = const char*
// 10 = whar_t*
// 11 = const wchar_t*
// 12 = string
typedef mpl::int_<1>::type std_container_;
typedef mpl::int_<2>::type std_pair_;
typedef mpl::int_<3>::type const_std_pair_;
typedef mpl::int_<4>::type array_;
typedef mpl::int_<5>::type const_array_;
typedef mpl::int_<6>::type char_array_;
typedef mpl::int_<7>::type wchar_t_array_;
typedef mpl::int_<8>::type char_ptr_;
typedef mpl::int_<9>::type const_char_ptr_;
typedef mpl::int_<10>::type wchar_t_ptr_;
typedef mpl::int_<11>::type const_wchar_t_ptr_;
typedef mpl::int_<12>::type string_;
template< typename C >
struct range_helper
{
static C* c;
static C ptr;
BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::value ));
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
};
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_,
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_,
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_,
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_,
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_,
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_,
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_,
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_,
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,
boost::range_detail::std_container_,
char_array_t >::type type;
}; // class 'range'
}
}
#endif

View file

@ -0,0 +1,71 @@
// 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_CONST_ITERATOR_HPP
#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_const_iterator_;
template<>
struct range_const_iterator_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::const_iterator type;
};
};
template<>
struct range_const_iterator_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_RANGE_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< typename C >
class range_const_iterator
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_const_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View file

@ -0,0 +1,101 @@
// 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_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/iterator.hpp>
# include <boost/range/detail/common.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/detail/remove_extent.hpp>
# endif
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
fun( C& c )
{
return c.end();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
fun( const P& p )
{
return p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( boost_range_array );
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
{
return t + remove_extent<T>::size;
}
#endif
};
} // namespace 'range_detail'
namespace range_adl_barrier
{
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace range_adl_barrier
} // namespace 'boost'
# endif // VC6
#endif

View file

@ -0,0 +1,52 @@
// Boost.Range library
//
// Copyright Arno Schoedl & Neil Groves 2009.
// 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_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
template< typename C > \
struct extract_ ## a_typedef \
{ \
typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
};
#else
namespace boost {
namespace range_detail {
template< typename T > struct exists { typedef void type; };
}
}
// Defines extract_some_typedef<T> which exposes T::some_typedef as
// extract_some_typedef<T>::type if T::some_typedef exists. Otherwise
// extract_some_typedef<T> is empty.
#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
template< typename C, typename Enable=void > \
struct extract_ ## a_typedef \
{}; \
template< typename C > \
struct extract_ ## a_typedef< C \
, BOOST_DEDUCED_TYPENAME boost::range_detail::exists< BOOST_DEDUCED_TYPENAME C::a_typedef >::type \
> { \
typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
};
#endif
#endif // include guard

View file

@ -0,0 +1,103 @@
// 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_IMPLEMENTATION_HELP_HPP
#define BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
#include <boost/range/config.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/type_traits/is_same.hpp>
#include <cstddef>
#include <string.h>
#ifndef BOOST_NO_CWCHAR
#include <wchar.h>
#endif
namespace boost
{
namespace range_detail
{
template <typename T>
inline void boost_range_silence_warning( const T& ) { }
/////////////////////////////////////////////////////////////////////
// end() help
/////////////////////////////////////////////////////////////////////
inline const char* str_end( const char* s, const char* )
{
return s + strlen( s );
}
#ifndef BOOST_NO_CWCHAR
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
return s + wcslen( s );
}
#else
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
if( s == 0 || s[0] == 0 )
return s;
while( *++s != 0 )
;
return s;
}
#endif
template< class 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] )
{
return boost_range_array + sz;
}
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost_range_array + sz;
}
/////////////////////////////////////////////////////////////////////
// size() help
/////////////////////////////////////////////////////////////////////
template< class Char >
inline std::size_t str_size( const Char* const& 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] )
{
boost_range_silence_warning( boost_range_array );
return sz;
}
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
boost_range_silence_warning( boost_range_array );
return sz;
}
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View file

@ -0,0 +1,78 @@
// 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_ITERATOR_HPP
#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.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_iterator_ {
template< typename C >
struct pts
{
typedef int type;
};
};
template<>
struct range_iterator_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type;
};
};
template<>
struct range_iterator_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_RANGE_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< typename C >
class range_mutable_iterator
{
typedef BOOST_RANGE_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;
};
}
#endif

View file

@ -0,0 +1,33 @@
// Boost.Range library concept checks
//
// Copyright Neil Groves 2009. Use, modification and distribution
// are 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)
//
#ifndef BOOST_RANGE_DETAIL_MISC_CONCEPT_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_MISC_CONCEPT_HPP_INCLUDED
#include <boost/concept_check.hpp>
namespace boost
{
namespace range_detail
{
template<typename T1, typename T2>
class SameTypeConcept
{
public:
BOOST_CONCEPT_USAGE(SameTypeConcept)
{
same_type(a,b);
}
private:
template<typename T> void same_type(T,T) {}
T1 a;
T2 b;
};
}
}
#endif // include guard

View file

@ -0,0 +1,157 @@
// 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

@ -0,0 +1,72 @@
// This header intentionally has no include guards.
//
// Copyright (c) 2010 Neil Groves
// Distributed under 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
//
// This code utilises the experience gained during the evolution of
// <boost/smart_ptr/operator_bool.hpp>
#ifndef BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
#define BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
#include <boost/config.hpp>
#include <boost/range/config.hpp>
namespace boost
{
namespace range_detail
{
template<class DataMemberPtr>
class safe_bool
{
public:
typedef safe_bool this_type;
#if (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570)) || defined(__CINT_)
typedef bool unspecified_bool_type;
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
{
return x;
}
#elif defined(_MANAGED)
static void unspecified_bool(this_type***)
{
}
typedef void(*unspecified_bool_type)(this_type***);
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
{
return x ? unspecified_bool : 0;
}
#elif \
( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
typedef bool (this_type::*unspecified_bool_type)() const;
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
{
return x ? &this_type::detail_safe_bool_member_fn : 0;
}
private:
bool detail_safe_bool_member_fn() const { return false; }
#else
typedef DataMemberPtr unspecified_bool_type;
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr p)
{
return x ? p : 0;
}
#endif
private:
safe_bool();
safe_bool(const safe_bool&);
void operator=(const safe_bool&);
~safe_bool();
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View file

@ -0,0 +1,77 @@
// 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_SFINAE_HPP
#define BOOST_RANGE_DETAIL_SFINAE_HPP
#include <boost/range/config.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <utility>
namespace boost
{
namespace range_detail
{
using type_traits::yes_type;
using type_traits::no_type;
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
yes_type is_string_impl( const char* const );
yes_type is_string_impl( const wchar_t* const );
no_type is_string_impl( ... );
template< std::size_t sz >
yes_type is_char_array_impl( char BOOST_RANGE_ARRAY_REF()[sz] );
template< std::size_t sz >
yes_type is_char_array_impl( const char BOOST_RANGE_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] );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( const wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
no_type is_wchar_t_array_impl( ... );
yes_type is_char_ptr_impl( char* const );
no_type is_char_ptr_impl( ... );
yes_type is_const_char_ptr_impl( const char* const );
no_type is_const_char_ptr_impl( ... );
yes_type is_wchar_t_ptr_impl( wchar_t* const );
no_type is_wchar_t_ptr_impl( ... );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* const );
no_type is_const_wchar_t_ptr_impl( ... );
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
yes_type is_pair_impl( const std::pair<Iterator,Iterator>* );
no_type is_pair_impl( ... );
//////////////////////////////////////////////////////////////////////
// tags
//////////////////////////////////////////////////////////////////////
struct char_or_wchar_t_array_tag {};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View file

@ -0,0 +1,55 @@
// 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_SIZE_TYPE_HPP
#define BOOST_RANGE_DETAIL_SIZE_TYPE_HPP
#include <boost/range/detail/common.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_size_type_
{
template< typename C >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::size_type type;
};
};
}
template< typename C >
class range_size
{
typedef 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;
};
}
#endif

View file

@ -0,0 +1,170 @@
// 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

@ -0,0 +1,29 @@
// 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_DIFFERENCE_TYPE_HPP
#define BOOST_RANGE_DIFFERENCE_TYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_difference : iterator_difference< typename range_iterator<T>::type >
{ };
}
#endif

View file

@ -0,0 +1,34 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2006. 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_DISTANCE_HPP
#define BOOST_RANGE_DISTANCE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/difference_type.hpp>
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type
distance( const T& r )
{
return std::distance( boost::begin( r ), boost::end( r ) );
}
} // namespace 'boost'
#endif

View file

@ -0,0 +1,34 @@
// 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_EMPTY_HPP
#define BOOST_RANGE_EMPTY_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
namespace boost
{
template< class T >
inline bool empty( const T& r )
{
return boost::begin( r ) == boost::end( r );
}
} // namespace 'boost'
#endif

View file

@ -0,0 +1,136 @@
// 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_END_HPP
#define BOOST_RANGE_END_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
#include <boost/range/detail/end.hpp>
#else
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/const_iterator.hpp>
namespace boost
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
namespace range_detail
{
#endif
//////////////////////////////////////////////////////////////////////
// primary template
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
range_end( C& c )
{
//
// If you get a compile-error here, it is most likely because
// you have not implemented range_begin() properly in
// the namespace of C
//
return c.end();
}
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
{
return p.second;
}
template< typename Iterator >
inline Iterator range_end( std::pair<Iterator,Iterator>& p )
{
return p.second;
}
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
inline const T* range_end( const T (&a)[sz] )
{
return range_detail::array_end<T,sz>( a );
}
template< typename T, std::size_t sz >
inline T* range_end( T (&a)[sz] )
{
return range_detail::array_end<T,sz>( a );
}
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
} // namespace 'range_detail'
#endif
namespace range_adl_barrier
{
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 range_end( r );
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_end( r );
}
} // namespace range_adl_barrier
} // namespace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
namespace range_adl_barrier
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_end( const T& r )
{
return boost::range_adl_barrier::end( r );
}
} // namespace range_adl_barrier
using namespace range_adl_barrier;
} // namespace boost
#endif

View file

@ -0,0 +1,27 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2006. 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_FUNCTIONS_HPP
#define BOOST_RANGE_FUNCTIONS_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/range/distance.hpp>
#include <boost/range/empty.hpp>
#include <boost/range/rbegin.hpp>
#include <boost/range/rend.hpp>
#endif

View file

@ -0,0 +1,72 @@
// 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_ITERATOR_HPP
#define BOOST_RANGE_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/mutable_iterator.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/mpl/eval_if.hpp>
namespace boost
{
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
namespace range_detail_vc7_1
{
template< typename C, typename Sig = void(C) >
struct range_iterator
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
mpl::eval_if_c< is_const<C>::value,
range_const_iterator< typename remove_const<C>::type >,
range_mutable_iterator<C> >::type type;
};
template< typename C, typename T >
struct range_iterator< C, void(T[]) >
{
typedef T* type;
};
}
#endif
template< typename C >
struct range_iterator
{
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
typedef BOOST_RANGE_DEDUCED_TYPENAME
range_detail_vc7_1::range_iterator<C>::type type;
#else
typedef BOOST_RANGE_DEDUCED_TYPENAME
mpl::eval_if_c< is_const<C>::value,
range_const_iterator< typename remove_const<C>::type >,
range_mutable_iterator<C> >::type type;
#endif
};
} // namespace boost
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View file

@ -0,0 +1,653 @@
// Boost.Range library
//
// Copyright Neil Groves & Thorsten Ottosen & Pavol Droba 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_ITERATOR_RANGE_CORE_HPP_INCLUDED
#define BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED
#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( push )
#pragma warning( disable : 4996 )
#endif
#include <boost/assert.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_abstract.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/algorithm/equal.hpp>
#include <boost/range/detail/safe_bool.hpp>
#include <boost/utility/enable_if.hpp>
#include <iterator>
#include <algorithm>
#include <cstddef>
/*! \file
Defines the \c iterator_class and related functions.
\c iterator_range is a simple wrapper of iterator pair idiom. It provides
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<class IteratorT>
struct iterator_range_impl {
template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r )
{
return static_cast<IteratorT>( boost::begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
return static_cast<IteratorT>( boost::end( r ) );
}
};
template< class Left, class Right >
inline bool less_than( const Left& l, const Right& r )
{
return std::lexicographical_compare( boost::begin(l),
boost::end(l),
boost::begin(r),
boost::end(r) );
}
template< class Left, class Right >
inline bool greater_than( const Left& l, const Right& r )
{
return less_than(r,l);
}
template< class Left, class Right >
inline bool less_or_equal_than( const Left& l, const Right& r )
{
return !iterator_range_detail::less_than(r,l);
}
template< class Left, class Right >
inline bool greater_or_equal_than( const Left& l, const Right& r )
{
return !iterator_range_detail::less_than(l,r);
}
// This version is maintained since it is used in other boost libraries
// such as Boost.Assign
template< class Left, class Right >
inline bool equal(const Left& l, const Right& r)
{
return boost::equal(l, r);
}
struct range_tag { };
struct const_range_tag { };
}
// iterator range template class -----------------------------------------//
//! iterator_range class
/*!
An \c iterator_range delimits a range in a sequence by beginning and ending iterators.
An iterator_range can be passed to an algorithm which requires a sequence as an input.
For example, the \c toupper() function may be used most frequently on strings,
but can also be used on iterator_ranges:
\code
boost::tolower( find( s, "UPPERCASE STRING" ) );
\endcode
Many algorithms working with sequences take a pair of iterators,
delimiting a working range, as an arguments. The \c iterator_range class is an
encapsulation of a range identified by a pair of iterators.
It provides a collection interface,
so it is possible to pass an instance to an algorithm requiring a collection as an input.
*/
template<class IteratorT>
class iterator_range
{
typedef range_detail::safe_bool< IteratorT iterator_range<IteratorT>::* > safe_bool_t;
protected: // Used by sub_range
//! implementation class
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
public:
//! this type
typedef iterator_range<IteratorT> type;
typedef BOOST_DEDUCED_TYPENAME safe_bool_t::unspecified_bool_type unspecified_bool_type;
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
//! Encapsulated value type
typedef BOOST_DEDUCED_TYPENAME
iterator_value<IteratorT>::type value_type;
//! Difference type
typedef BOOST_DEDUCED_TYPENAME
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;
//! Reference type
//
// Needed because value-type is the same for
// const and non-const iterators
//
typedef BOOST_DEDUCED_TYPENAME
iterator_reference<IteratorT>::type reference;
//! const_iterator type
/*!
There is no distinction between const_iterator and iterator.
These typedefs are provides to fulfill container interface
*/
typedef IteratorT const_iterator;
//! iterator type
typedef IteratorT iterator;
private: // for return value of operator()()
typedef BOOST_DEDUCED_TYPENAME
boost::mpl::if_< boost::mpl::or_< boost::is_abstract< value_type >,
boost::is_array< value_type > >,
reference, value_type >::type abstract_value_type;
public:
iterator_range() : m_Begin( iterator() ), m_End( iterator() )
{ }
//! Constructor from a pair of iterators
template< class Iterator >
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 ) )
{}
//! Constructor from a Range
template< class Range >
iterator_range( Range& r ) :
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_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 ) )
{}
//! 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 ) )
{}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
this_type& operator=( const this_type& r )
{
m_Begin = r.begin();
m_End = r.end();
return *this;
}
#endif
template< class Iterator >
iterator_range& operator=( const iterator_range<Iterator>& r )
{
m_Begin = r.begin();
m_End = r.end();
return *this;
}
template< class ForwardRange >
iterator_range& operator=( ForwardRange& r )
{
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
return *this;
}
template< class ForwardRange >
iterator_range& operator=( const ForwardRange& r )
{
m_Begin = impl::adl_begin( r );
m_End = impl::adl_end( r );
return *this;
}
IteratorT begin() const
{
return m_Begin;
}
IteratorT end() const
{
return m_End;
}
difference_type size() const
{
return m_End - m_Begin;
}
bool empty() const
{
return m_Begin == m_End;
}
operator unspecified_bool_type() const
{
return safe_bool_t::to_unspecified_bool(m_Begin != m_End, &iterator_range::m_Begin);
}
bool operator!() const
{
return empty();
}
bool equal( const iterator_range& r ) const
{
return m_Begin == r.m_Begin && m_End == r.m_End;
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
bool operator==( const iterator_range& r ) const
{
return boost::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 );
}
bool operator>( const iterator_range& r ) const
{
return iterator_range_detail::greater_than( *this, r );
}
bool operator<=( const iterator_range& r ) const
{
return iterator_range_detail::less_or_equal_than( *this, r );
}
bool operator>=( const iterator_range& r ) const
{
return iterator_range_detail::greater_or_equal_than( *this, r );
}
#endif
public: // convenience
reference front() const
{
BOOST_ASSERT( !empty() );
return *m_Begin;
}
reference back() const
{
BOOST_ASSERT( !empty() );
IteratorT last( m_End );
return *--last;
}
// pop_front() - added to model the SinglePassRangePrimitiveConcept
void pop_front()
{
BOOST_ASSERT( !empty() );
++m_Begin;
}
// pop_back() - added to model the BidirectionalRangePrimitiveConcept
void pop_back()
{
BOOST_ASSERT( !empty() );
--m_End;
}
reference operator[]( difference_type at ) const
{
BOOST_ASSERT( at >= 0 && at < size() );
return m_Begin[at];
}
//
// When storing transform iterators, operator[]()
// fails because it returns by reference. Therefore
// operator()() is provided for these cases.
//
abstract_value_type operator()( difference_type at ) const
{
BOOST_ASSERT( at >= 0 && at < size() );
return m_Begin[at];
}
iterator_range& advance_begin( difference_type n )
{
std::advance( m_Begin, n );
return *this;
}
iterator_range& advance_end( difference_type n )
{
std::advance( m_End, n );
return *this;
}
private:
// begin and end iterators
IteratorT m_Begin;
IteratorT m_End;
protected:
//
// Allow subclasses an easy way to access the
// base type
//
typedef iterator_range iterator_range_;
};
// iterator range free-standing operators ---------------------------//
/////////////////////////////////////////////////////////////////////
// comparison operators
/////////////////////////////////////////////////////////////////////
template< class IteratorT, class ForwardRange >
inline bool operator==( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return boost::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator!=( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return !boost::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 );
}
template< class IteratorT, class ForwardRange >
inline bool operator<=( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::less_or_equal_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator>( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::greater_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator>=( const ForwardRange& l,
const iterator_range<IteratorT>& r )
{
return iterator_range_detail::greater_or_equal_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 boost::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator==( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return boost::equal( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator!=( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return !boost::equal( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator!=( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return !boost::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 );
}
template< class Iterator1T, class Iterator2T >
inline bool operator<=( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::less_or_equal_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator<=( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::less_or_equal_than( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator>( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::greater_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator>( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::greater_than( l, r );
}
template< class Iterator1T, class Iterator2T >
inline bool operator>=( const iterator_range<Iterator1T>& l,
const iterator_range<Iterator2T>& r )
{
return iterator_range_detail::greater_or_equal_than( l, r );
}
template< class IteratorT, class ForwardRange >
inline bool operator>=( const iterator_range<IteratorT>& l,
const ForwardRange& r )
{
return iterator_range_detail::greater_or_equal_than( l, r );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
// iterator range utilities -----------------------------------------//
//! iterator_range construct helper
/*!
Construct an \c iterator_range from a pair of iterators
\param Begin A begin iterator
\param End An end iterator
\return iterator_range object
*/
template< typename IteratorT >
inline iterator_range< IteratorT >
make_iterator_range( IteratorT Begin, IteratorT End )
{
return iterator_range<IteratorT>( Begin, End );
}
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< typename Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
make_iterator_range( Range& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
( boost::begin( r ), boost::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 )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
( r, iterator_range_detail::range_tag() );
}
template< class ForwardRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
make_iterator_range( const ForwardRange& r )
{
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
( r, iterator_range_detail::const_range_tag() );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace iterator_range_detail
{
template< class Range >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_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 )
{
//
// Not worth the effort
//
//if( advance_begin == 0 && advance_end == 0 )
// return make_iterator_range( r );
//
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
new_begin = boost::begin( r ),
new_end = boost::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_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_iterator<const 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
in the given range
\param Range An input range
\return New sequence
*/
template< typename SeqT, typename Range >
inline SeqT copy_range( const Range& r )
{
return SeqT( boost::begin( r ), boost::end( r ) );
}
} // namespace 'boost'
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
#pragma warning( pop )
#endif
#endif

View file

@ -0,0 +1,67 @@
// 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_MUTABLE_ITERATOR_HPP
#define BOOST_RANGE_MUTABLE_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/iterator.hpp>
#else
#include <boost/range/detail/extract_optional_type.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
namespace range_detail {
BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( iterator )
}
template< typename C >
struct range_mutable_iterator : range_detail::extract_iterator<C>
{};
//////////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_mutable_iterator< std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
//////////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_mutable_iterator< T[sz] >
{
typedef T* type;
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View file

@ -0,0 +1,65 @@
// 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_RBEGIN_HPP
#define BOOST_RANGE_RBEGIN_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/end.hpp>
#include <boost/range/reverse_iterator.hpp>
namespace boost
{
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rbegin( C& c )
{
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::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( boost::end( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
rbegin( const C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
iter_type;
return iter_type( boost::end( c ) );
}
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class T >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
const_rbegin( const T& r )
{
return boost::rbegin( r );
}
} // namespace 'boost'
#endif

View file

@ -0,0 +1,65 @@
// 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_REND_HPP
#define BOOST_RANGE_REND_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/begin.hpp>
#include <boost/range/reverse_iterator.hpp>
namespace boost
{
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
rend( C& c )
{
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::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( boost::begin( c ) );
}
template< class C >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
rend( const C& c )
{
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
iter_type;
return iter_type( boost::begin( c ) );
}
#endif
template< class T >
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
const_rend( const T& r )
{
return boost::rend( r );
}
} // namespace 'boost'
#endif

View file

@ -0,0 +1,33 @@
// 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_RESULT_ITERATOR_HPP
#define BOOST_RANGE_RESULT_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/range/iterator.hpp>
namespace boost
{
//
// This interface is deprecated, use range_iterator<T>
//
template< typename C >
struct range_result_iterator : range_iterator<C>
{ };
} // namespace boost
#endif

View file

@ -0,0 +1,40 @@
// 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_REVERSE_ITERATOR_HPP
#define BOOST_RANGE_REVERSE_ITERATOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/iterator/reverse_iterator.hpp>
namespace boost
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
template< typename C >
struct range_reverse_iterator
{
typedef reverse_iterator<
BOOST_DEDUCED_TYPENAME range_iterator<C>::type > type;
};
} // namespace boost
#endif

View file

@ -0,0 +1,52 @@
// 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_SIZE_HPP
#define BOOST_RANGE_SIZE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size_type.hpp>
#include <boost/assert.hpp>
namespace boost
{
namespace range_detail
{
template<class SinglePassRange>
inline BOOST_DEDUCED_TYPENAME range_size<const SinglePassRange>::type
range_calculate_size(const SinglePassRange& rng)
{
BOOST_ASSERT( (boost::end(rng) - boost::begin(rng)) >= 0 &&
"reachability invariant broken!" );
return boost::end(rng) - boost::begin(rng);
}
}
template<class SinglePassRange>
inline BOOST_DEDUCED_TYPENAME range_size<const SinglePassRange>::type
size(const SinglePassRange& rng)
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_calculate_size(rng);
}
} // namespace 'boost'
#endif

View file

@ -0,0 +1,89 @@
// 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_SIZE_TYPE_HPP
#define BOOST_RANGE_SIZE_TYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/difference_type.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/size_type.hpp>
#else
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <cstddef>
#include <utility>
namespace boost
{
namespace detail
{
//////////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////////
template<typename T>
class has_size_type
{
typedef char no_type;
struct yes_type { char dummy[2]; };
template<typename C>
static yes_type test(BOOST_DEDUCED_TYPENAME C::size_type x);
template<typename C, typename Arg>
static no_type test(Arg x);
public:
static const bool value = sizeof(test<T>(0)) == sizeof(yes_type);
};
template<typename C, typename Enabler=void>
struct range_size
{
typedef BOOST_DEDUCED_TYPENAME make_unsigned<
BOOST_DEDUCED_TYPENAME range_difference<C>::type
>::type type;
};
template<typename C>
struct range_size<
C,
BOOST_DEDUCED_TYPENAME enable_if<has_size_type<C>, void>::type
>
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
}
template< class T >
struct range_size :
detail::range_size<T>
{ };
template< class T >
struct range_size<const T >
: detail::range_size<T>
{ };
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif

View file

@ -0,0 +1,34 @@
// 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_VALUE_TYPE_HPP
#define BOOST_RANGE_VALUE_TYPE_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//#include <boost/range/detail/value_type.hpp>
//#else
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_value : iterator_value< typename range_iterator<T>::type >
{ };
}
#endif