early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -0,0 +1,589 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. 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_ANY_ITERATOR_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_HPP_INCLUDED
#include <boost/mpl/and.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/not.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/range/detail/any_iterator_buffer.hpp>
#include <boost/range/detail/any_iterator_interface.hpp>
#include <boost/range/detail/any_iterator_wrapper.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost
{
namespace range_detail
{
// metafunction to determine if T is a const reference
template<class T>
struct is_const_reference
{
typedef typename mpl::and_<
typename is_reference<T>::type,
typename is_const<
typename remove_reference<T>::type
>::type
>::type type;
};
// metafunction to determine if T is a mutable reference
template<class T>
struct is_mutable_reference
{
typedef typename mpl::and_<
typename is_reference<T>::type,
typename mpl::not_<
typename is_const<
typename remove_reference<T>::type
>::type
>::type
>::type type;
};
// metafunction to evaluate if a source 'reference' can be
// converted to a target 'reference' as a value.
//
// This is true, when the target reference type is actually
// not a reference, and the source reference is convertible
// to the target type.
template<class SourceReference, class TargetReference>
struct is_convertible_to_value_as_reference
{
typedef typename mpl::and_<
typename mpl::not_<
typename is_reference<TargetReference>::type
>::type
, typename is_convertible<
SourceReference
, TargetReference
>::type
>::type type;
};
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer = any_iterator_default_buffer
>
class any_iterator;
// metafunction to determine if SomeIterator is an
// any_iterator.
//
// This is the general implementation which evaluates to false.
template<class SomeIterator>
struct is_any_iterator
: mpl::bool_<false>
{
};
// specialization of is_any_iterator to return true for
// any_iterator classes regardless of template parameters.
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
struct is_any_iterator<
any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
>
: mpl::bool_<true>
{
};
} // namespace range_detail
namespace iterators
{
namespace detail
{
// Rationale:
// These are specialized since the iterator_facade versions lack
// the requisite typedefs to allow wrapping to determine the types
// if a user copy constructs from a postfix increment.
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
class postfix_increment_proxy<
range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
>
{
typedef range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
> any_iterator_type;
public:
typedef Value value_type;
typedef typename std::iterator_traits<any_iterator_type>::iterator_category iterator_category;
typedef Difference difference_type;
typedef typename iterator_pointer<any_iterator_type>::type pointer;
typedef Reference reference;
explicit postfix_increment_proxy(any_iterator_type const& x)
: stored_value(*x)
{}
value_type&
operator*() const
{
return this->stored_value;
}
private:
mutable value_type stored_value;
};
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
class writable_postfix_increment_proxy<
range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
>
{
typedef range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
> any_iterator_type;
public:
typedef Value value_type;
typedef typename std::iterator_traits<any_iterator_type>::iterator_category iterator_category;
typedef Difference difference_type;
typedef typename iterator_pointer<any_iterator_type>::type pointer;
typedef Reference reference;
explicit writable_postfix_increment_proxy(any_iterator_type const& x)
: stored_value(*x)
, stored_iterator(x)
{}
// Dereferencing must return a proxy so that both *r++ = o and
// value_type(*r++) can work. In this case, *r is the same as
// *r++, and the conversion operator below is used to ensure
// readability.
writable_postfix_increment_proxy const&
operator*() const
{
return *this;
}
// Provides readability of *r++
operator value_type&() const
{
return stored_value;
}
// Provides writability of *r++
template <class T>
T const& operator=(T const& x) const
{
*this->stored_iterator = x;
return x;
}
// This overload just in case only non-const objects are writable
template <class T>
T& operator=(T& x) const
{
*this->stored_iterator = x;
return x;
}
// Provides X(r++)
operator any_iterator_type const&() const
{
return stored_iterator;
}
private:
mutable value_type stored_value;
any_iterator_type stored_iterator;
};
} //namespace detail
} //namespace iterators
namespace range_detail
{
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
class any_iterator
: public iterator_facade<
any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
, Value
, Traversal
, Reference
, Difference
>
{
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
, class OtherBuffer
>
friend class any_iterator;
struct enabler {};
struct disabler {};
typedef typename any_iterator_interface_type_generator<
Traversal
, Reference
, Difference
, Buffer
>::type abstract_base_type;
typedef iterator_facade<
any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
, Value
, Traversal
, Reference
, Difference
> base_type;
typedef Buffer buffer_type;
public:
typedef typename base_type::value_type value_type;
typedef typename base_type::reference reference;
typedef typename base_type::difference_type difference_type;
// Default constructor
any_iterator()
: m_impl(0) {}
// Simple copy construction without conversion
any_iterator(const any_iterator& other)
: base_type(other)
, m_impl(other.m_impl
? other.m_impl->clone(m_buffer)
: 0)
{
}
// Simple assignment operator without conversion
any_iterator& operator=(const any_iterator& other)
{
if (this != &other)
{
if (m_impl)
m_impl->~abstract_base_type();
m_buffer.deallocate();
m_impl = 0;
if (other.m_impl)
m_impl = other.m_impl->clone(m_buffer);
}
return *this;
}
// Implicit conversion from another any_iterator where the
// conversion is from a non-const reference to a const reference
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_iterator(const any_iterator<
OtherValue,
OtherTraversal,
OtherReference,
OtherDifference,
Buffer
>& other,
typename ::boost::enable_if<
typename mpl::and_<
typename is_mutable_reference<OtherReference>::type,
typename is_const_reference<Reference>::type
>::type,
enabler
>::type* = 0
)
: m_impl(other.m_impl
? other.m_impl->clone_const_ref(m_buffer)
: 0
)
{
}
// Implicit conversion from another any_iterator where the
// reference types of the source and the target are references
// that are either both const, or both non-const.
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_iterator(const any_iterator<
OtherValue
, OtherTraversal
, OtherReference
, OtherDifference
, Buffer
>& other,
typename ::boost::enable_if<
typename mpl::or_<
typename mpl::and_<
typename is_mutable_reference<OtherReference>::type,
typename is_mutable_reference<Reference>::type
>::type,
typename mpl::and_<
typename is_const_reference<OtherReference>::type,
typename is_const_reference<Reference>::type
>::type
>::type,
enabler
>::type* = 0
)
: m_impl(other.m_impl
? other.m_impl->clone(m_buffer)
: 0
)
{
}
// Implicit conversion to an any_iterator that uses a value for
// the reference type.
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_iterator(const any_iterator<
OtherValue
, OtherTraversal
, OtherReference
, OtherDifference
, Buffer
>& other,
typename ::boost::enable_if<
typename is_convertible_to_value_as_reference<
OtherReference
, Reference
>::type,
enabler
>::type* = 0
)
: m_impl(other.m_impl
? other.m_impl->clone_reference_as_value(m_buffer)
: 0
)
{
}
any_iterator clone() const
{
any_iterator result;
if (m_impl)
result.m_impl = m_impl->clone(result.m_buffer);
return result;
}
any_iterator<
Value
, Traversal
, typename abstract_base_type::const_reference
, Difference
, Buffer
>
clone_const_ref() const
{
typedef any_iterator<
Value
, Traversal
, typename abstract_base_type::const_reference
, Difference
, Buffer
> result_type;
result_type result;
if (m_impl)
result.m_impl = m_impl->clone_const_ref(result.m_buffer);
return result;
}
// implicit conversion and construction from type-erasure-compatible
// iterators
template<class WrappedIterator>
explicit any_iterator(
const WrappedIterator& wrapped_iterator,
typename disable_if<
typename is_any_iterator<WrappedIterator>::type
, disabler
>::type* = 0
)
{
typedef typename any_iterator_wrapper_type_generator<
WrappedIterator
, Traversal
, Reference
, Difference
, Buffer
>::type wrapper_type;
void* ptr = m_buffer.allocate(sizeof(wrapper_type));
m_impl = new(ptr) wrapper_type(wrapped_iterator);
}
~any_iterator()
{
// manually run the destructor, the deallocation is automatically
// handled by the any_iterator_small_buffer base class.
if (m_impl)
m_impl->~abstract_base_type();
}
private:
friend class ::boost::iterator_core_access;
Reference dereference() const
{
BOOST_ASSERT( m_impl );
return m_impl->dereference();
}
bool equal(const any_iterator& other) const
{
return (m_impl == other.m_impl)
|| (m_impl && other.m_impl && m_impl->equal(*other.m_impl));
}
void increment()
{
BOOST_ASSERT( m_impl );
m_impl->increment();
}
void decrement()
{
BOOST_ASSERT( m_impl );
m_impl->decrement();
}
Difference distance_to(const any_iterator& other) const
{
return m_impl && other.m_impl
? m_impl->distance_to(*other.m_impl)
: 0;
}
void advance(Difference offset)
{
BOOST_ASSERT( m_impl );
m_impl->advance(offset);
}
any_iterator& swap(any_iterator& other)
{
BOOST_ASSERT( this != &other );
// grab a temporary copy of the other iterator
any_iterator tmp(other);
// deallocate the other iterator, taking care to obey the
// class-invariants in-case of exceptions later
if (other.m_impl)
{
other.m_impl->~abstract_base_type();
other.m_buffer.deallocate();
other.m_impl = 0;
}
// If this is a non-null iterator then we need to put
// a clone of this iterators implementation into the other
// iterator.
// We can't just swap because of the small buffer optimization.
if (m_impl)
{
other.m_impl = m_impl->clone(other.m_buffer);
m_impl->~abstract_base_type();
m_buffer.deallocate();
m_impl = 0;
}
// assign to this instance a clone of the temporarily held
// tmp which represents the input other parameter at the
// start of execution of this function.
if (tmp.m_impl)
m_impl = tmp.m_impl->clone(m_buffer);
return *this;
}
buffer_type m_buffer;
abstract_base_type* m_impl;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,117 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. 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_ANY_ITERATOR_BUFFER_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_BUFFER_HPP_INCLUDED
#include <boost/array.hpp>
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/noncopyable.hpp>
namespace boost
{
template<std::size_t StackBufferSize>
class any_iterator_buffer
: noncopyable
{
BOOST_STATIC_ASSERT(( StackBufferSize > 0 ));
public:
any_iterator_buffer()
: m_ptr()
{
}
~any_iterator_buffer()
{
delete [] m_ptr;
}
void* allocate(std::size_t bytes)
{
BOOST_ASSERT( !m_ptr );
if (bytes <= StackBufferSize)
return m_buffer.data();
m_ptr = new char[bytes];
return m_ptr;
}
void deallocate()
{
delete [] m_ptr;
m_ptr = 0;
}
private:
// Rationale:
// Do not use inheritance from noncopyable because this causes
// the concepts to erroneous detect the derived any_iterator
// as noncopyable.
any_iterator_buffer(const any_iterator_buffer&);
void operator=(const any_iterator_buffer&);
char* m_ptr;
boost::array<char, StackBufferSize> m_buffer;
};
class any_iterator_heap_only_buffer
: noncopyable
{
public:
any_iterator_heap_only_buffer()
: m_ptr()
{
}
~any_iterator_heap_only_buffer()
{
delete [] m_ptr;
}
void* allocate(std::size_t bytes)
{
BOOST_ASSERT( !m_ptr );
m_ptr = new char[bytes];
return m_ptr;
}
void deallocate()
{
delete [] m_ptr;
m_ptr = 0;
}
private:
char* m_ptr;
};
template<std::size_t StackBufferSize>
class any_iterator_stack_only_buffer
{
BOOST_STATIC_ASSERT(( StackBufferSize > 0 ));
public:
void* allocate(std::size_t bytes)
{
BOOST_ASSERT( bytes <= m_buffer.size() );
return m_buffer.data();
}
void deallocate()
{
}
private:
boost::array<char, StackBufferSize> m_buffer;
};
typedef any_iterator_buffer<64> any_iterator_default_buffer;
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,273 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. 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_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
#include <boost/range/detail/any_iterator_buffer.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost
{
namespace range_detail
{
template<class T>
struct const_reference_type_generator
{
typedef typename mpl::if_<
typename is_reference<T>::type,
typename add_const<
typename remove_reference<T>::type
>::type&,
T
>::type type;
};
template<class T>
struct reference_as_value_type_generator
{
typedef typename remove_reference<
typename remove_const<T>::type
>::type value_type;
typedef typename mpl::if_<
typename is_convertible<const value_type&, value_type>::type,
value_type,
T
>::type type;
};
template<
class Reference
, class Buffer
>
struct any_incrementable_iterator_interface
{
typedef Reference reference;
typedef typename const_reference_type_generator<
Reference
>::type const_reference;
typedef typename reference_as_value_type_generator<
Reference
>::type reference_as_value_type;
typedef Buffer buffer_type;
virtual ~any_incrementable_iterator_interface() {}
virtual any_incrementable_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_incrementable_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_incrementable_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual void increment() = 0;
};
template<
class Reference
, class Buffer
>
struct any_single_pass_iterator_interface
: any_incrementable_iterator_interface<Reference, Buffer>
{
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
virtual any_single_pass_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_single_pass_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_single_pass_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual reference dereference() const = 0;
virtual bool equal(const any_single_pass_iterator_interface& other) const = 0;
};
template<
class Reference
, class Buffer
>
struct any_forward_iterator_interface
: any_single_pass_iterator_interface<Reference, Buffer>
{
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
virtual any_forward_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_forward_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_forward_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
};
template<
class Reference
, class Buffer
>
struct any_bidirectional_iterator_interface
: any_forward_iterator_interface<Reference, Buffer>
{
typedef typename any_forward_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_forward_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_forward_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_forward_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
virtual any_bidirectional_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_bidirectional_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_bidirectional_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual void decrement() = 0;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_random_access_iterator_interface
: any_bidirectional_iterator_interface<
Reference
, Buffer
>
{
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
typedef Difference difference_type;
virtual any_random_access_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_random_access_iterator_interface<const_reference, Difference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_random_access_iterator_interface<reference_as_value_type, Difference, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual void advance(Difference offset) = 0;
virtual Difference distance_to(const any_random_access_iterator_interface& other) const = 0;
};
template<
class Traversal
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator;
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
incrementable_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_incrementable_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
single_pass_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_single_pass_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
forward_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_forward_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
bidirectional_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_bidirectional_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
random_access_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_random_access_iterator_interface<
Reference
, Difference
, Buffer
> type;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,640 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. 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_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
#include <boost/polymorphic_cast.hpp>
#include <boost/range/config.hpp>
#include <boost/range/detail/any_iterator_interface.hpp>
#include <boost/range/concepts.hpp>
namespace boost
{
namespace range_detail
{
template<typename TargetT, typename SourceT>
TargetT& polymorphic_ref_downcast(SourceT& source)
{
#ifdef BOOST_NO_RTTI
return static_cast<TargetT&>(source);
#else
return *boost::polymorphic_downcast<TargetT*>(&source);
#endif
}
template<class Reference, class T>
Reference dereference_cast(T& x)
{
return static_cast<Reference>(x);
}
template<class Reference, class T>
Reference dereference_cast(const T& x)
{
return static_cast<Reference>(const_cast<T&>(x));
}
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_incrementable_iterator_wrapper
: public any_incrementable_iterator_interface<
Reference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( IncrementableIteratorConcept<WrappedIterator> ));
public:
typedef WrappedIterator wrapped_type;
BOOST_STATIC_ASSERT(( is_convertible<
typename iterator_reference<WrappedIterator>::type
, Reference
>::value ));
any_incrementable_iterator_wrapper()
: m_it()
{}
explicit any_incrementable_iterator_wrapper(wrapped_type it)
: m_it(it)
{}
// any_incrementable_iterator implementation
virtual any_incrementable_iterator_wrapper* clone(
typename any_incrementable_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_incrementable_iterator_wrapper(m_it);
}
virtual any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_incrementable_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_incrementable_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
private:
wrapped_type m_it;
};
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_single_pass_iterator_wrapper
: public any_single_pass_iterator_interface<
Reference
, Buffer
>
{
struct disabler {};
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassIteratorConcept<WrappedIterator> ));
typedef any_single_pass_iterator_interface<
Reference,
Buffer
> base_type;
public:
typedef typename base_type::reference reference;
any_single_pass_iterator_wrapper()
: m_it()
{}
explicit any_single_pass_iterator_wrapper(const WrappedIterator& it)
: m_it(it)
{}
// any_single_pass_iterator_interface<Reference> implementation
virtual any_single_pass_iterator_wrapper* clone(
typename any_single_pass_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_single_pass_iterator_wrapper(m_it);
}
virtual any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_single_pass_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_single_pass_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == range_detail::polymorphic_ref_downcast<const any_single_pass_iterator_wrapper>(other).m_it;
}
virtual reference dereference() const
{
return dereference_cast<reference>(*m_it);
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_forward_iterator_wrapper
: public any_forward_iterator_interface<
Reference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardIteratorConcept<WrappedIterator> ));
typedef any_forward_iterator_interface<
Reference,
Buffer
> base_type;
public:
typedef typename base_type::reference reference;
any_forward_iterator_wrapper()
: m_it()
{}
explicit any_forward_iterator_wrapper(const WrappedIterator& it)
: m_it(it)
{}
// any_forward_iterator_interface<Reference> implementation
virtual any_forward_iterator_wrapper* clone(
typename any_forward_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_forward_iterator_wrapper(m_it);
}
virtual any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_forward_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_forward_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == range_detail::polymorphic_ref_downcast<const any_forward_iterator_wrapper>(other).m_it;
}
virtual reference dereference() const
{
return dereference_cast<reference>(*m_it);
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_bidirectional_iterator_wrapper
: public any_bidirectional_iterator_interface<
Reference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalIteratorConcept<WrappedIterator> ));
typedef any_bidirectional_iterator_interface<
Reference,
Buffer
> base_type;
public:
typedef typename base_type::reference reference;
any_bidirectional_iterator_wrapper()
: m_it()
{
}
explicit any_bidirectional_iterator_wrapper(const WrappedIterator& it)
: m_it(it)
{
}
virtual any_bidirectional_iterator_wrapper* clone(
typename any_bidirectional_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_bidirectional_iterator_wrapper(*this);
}
virtual any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_bidirectional_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_bidirectional_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual void decrement()
{
--m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == range_detail::polymorphic_ref_downcast<const any_bidirectional_iterator_wrapper>(other).m_it;
}
virtual reference dereference() const
{
return dereference_cast<reference>(*m_it);
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
class any_random_access_iterator_wrapper
: public any_random_access_iterator_interface<
Reference
, Difference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessIteratorConcept<WrappedIterator> ));
typedef any_random_access_iterator_interface<
Reference,
Difference,
Buffer
> base_type;
public:
typedef typename base_type::reference reference;
typedef Difference difference_type;
any_random_access_iterator_wrapper()
: m_it()
{
}
explicit any_random_access_iterator_wrapper(const WrappedIterator& other)
: m_it(other)
{
}
virtual any_random_access_iterator_wrapper* clone(
typename any_random_access_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_random_access_iterator_wrapper(*this);
}
virtual any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::const_reference
, Difference
, Buffer
>* clone_const_ref(
typename any_random_access_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::const_reference
, Difference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::reference_as_value_type
, Difference
, Buffer
>* clone_reference_as_value(
typename any_random_access_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::reference_as_value_type
, Difference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == range_detail::polymorphic_ref_downcast<const any_random_access_iterator_wrapper>(other).m_it;
}
virtual void decrement()
{
--m_it;
}
virtual void advance(Difference offset)
{
m_it += offset;
}
virtual reference dereference() const
{
return dereference_cast<reference>(*m_it);
}
virtual Difference distance_to(const any_random_access_iterator_interface<Reference, Difference, Buffer>& other) const
{
return range_detail::polymorphic_ref_downcast<const any_random_access_iterator_wrapper>(other).m_it - m_it;
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Traversal
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator;
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, incrementable_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_incrementable_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, single_pass_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_single_pass_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, forward_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_forward_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, bidirectional_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_bidirectional_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, random_access_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_random_access_iterator_wrapper<
WrappedIterator
, Reference
, Difference
, Buffer
> type;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,237 @@
// 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/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 typename ::boost::mpl::eval_if<
::boost::algorithm::detail::is_pair<T>,
detail::pair_container_traits_selector<T>,
typename ::boost::mpl::eval_if<
::boost::is_array<T>,
detail::array_container_traits_selector<T>,
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 typename
container_helper_type::value_type value_type;
//! Size type
typedef typename
container_helper_type::size_type size_type;
//! Iterator type
typedef typename
container_helper_type::iterator iterator;
//! Const iterator type
typedef typename
container_helper_type::const_iterator const_iterator;
//! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
typedef typename
container_helper_type::result_iterator result_iterator;
//! Difference type
typedef 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 typename collection_traits<C>::value_type type;
};
//! Container difference trait
/*!
Extract the container's difference type
*/
template< typename C >
struct difference_type_of
{
typedef typename collection_traits<C>::difference_type type;
};
//! Container iterator trait
/*!
Extract the container's iterator type
*/
template< typename C >
struct iterator_of
{
typedef 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 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 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 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 );
}
//! Free-standing begin() function
/*!
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline 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 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 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 typename collection_traits<C>::const_iterator
end( const C& c )
{
return collection_traits<C>::function_type::end( c );
}
} // namespace algorithm
} // namespace boost
#endif // BOOST_STRING_COLLECTION_TRAITS_HPP

View File

@@ -0,0 +1,447 @@
// 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 <cstddef>
#include <string>
#include <utility>
#include <iterator>
#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>
// 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 typename ContainerT::value_type value_type;
typedef typename ContainerT::iterator iterator;
typedef typename ContainerT::const_iterator const_iterator;
typedef typename
::boost::mpl::if_< ::boost::is_const<ContainerT>,
const_iterator,
iterator
>::type result_iterator;
typedef typename ContainerT::difference_type difference_type;
typedef 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();
}
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();
}
};
template<typename T>
struct default_container_traits_selector
{
typedef default_container_traits<T> type;
};
// Pair container traits ---------------------------------------------------------------------
typedef double yes_type;
typedef char no_type;
// 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 typename PairT::first_type element_type;
typedef typename
std::iterator_traits<element_type>::value_type value_type;
typedef std::size_t size_type;
typedef typename
std::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 ---------------------------------------------------------------
// 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 );
};
// array length resolving
/*
Lenght of string contained in a static array could
be different from the size of the array.
For string processing we need the length without
terminating 0.
Therefore, the length is calculated 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 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 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 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 typename
traits_type::value_type value_type;
typedef typename
traits_type::iterator iterator;
typedef typename
traits_type::const_iterator const_iterator;
typedef typename
traits_type::size_type size_type;
typedef typename
traits_type::difference_type difference_type;
typedef typename
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator
>::type result_iterator;
private:
// resolve array size
typedef typename
::boost::remove_cv<value_type>::type char_type;
typedef 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);
}
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);
}
};
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 typename
::boost::remove_pointer<T>::type value_type;
typedef 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 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;
}
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);
}
};
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

@@ -0,0 +1,79 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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_COMBINE_CXX03_HPP
#define BOOST_RANGE_DETAIL_COMBINE_CXX03_HPP
#ifndef BOOST_RANGE_MIN_COMBINE_ARGS
#define BOOST_RANGE_MIN_COMBINE_ARGS 2
#endif
#ifndef BOOST_RANGE_MAX_COMBINE_ARGS
#define BOOST_RANGE_MAX_COMBINE_ARGS 5
#endif
#include <boost/config.hpp>
#include <boost/iterator/zip_iterator.hpp>
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/arithmetic/div.hpp>
#include <boost/preprocessor/arithmetic/mul.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/control/while.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#include <boost/preprocessor/facilities/identity.hpp>
#include <boost/preprocessor/iteration/local.hpp>
#include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost
{
namespace range
{
#define BOOST_RANGE_combined_seq(z, n, data) boost::data(BOOST_PP_CAT(r,n))
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
#include <boost/range/detail/combine_no_rvalue.hpp>
#else // by using rvalue references we avoid requiring 2^n overloads.
#include <boost/range/detail/combine_rvalue.hpp>
#endif
#define BOOST_PP_LOCAL_MACRO(n) BOOST_RANGE_combine(~,n,~)
#define BOOST_PP_LOCAL_LIMITS (BOOST_RANGE_MIN_COMBINE_ARGS, \
BOOST_RANGE_MAX_COMBINE_ARGS)
#include BOOST_PP_LOCAL_ITERATE()
} // namespace range
using boost::range::combine;
} // namespace boost
#endif // include guard
#undef BOOST_RANGE_combined_seq
#undef BOOST_RANGE_combined_exp_pred
#undef BOOST_RANGE_combined_exp_op
#undef BOOST_RANGE_combined_exp
#undef BOOST_RANGE_combined_bitset_pred
#undef BOOST_RANGE_combined_bitset_op
#undef BOOST_RANGE_combined_bitset
#undef BOOST_RANGE_combined_range_iterator
#undef BOOST_RANGE_combined_args
#undef BOOST_RANGE_combine_impl
#undef BOOST_RANGE_combine

View File

@@ -0,0 +1,38 @@
// Copyright Neil Groves 2014. 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_COMBINE_CXX11_HPP
#define BOOST_RANGE_DETAIL_COMBINE_CXX11_HPP
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/iterator/zip_iterator.hpp>
namespace boost
{
namespace range
{
template<typename... Ranges>
auto combine(Ranges&&... rngs) ->
combined_range<decltype(boost::make_tuple(boost::begin(rngs)...))>
{
return combined_range<decltype(boost::make_tuple(boost::begin(rngs)...))>(
boost::make_tuple(boost::begin(rngs)...),
boost::make_tuple(boost::end(rngs)...));
}
} // namespace range
using range::combine;
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,73 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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/
//
#define BOOST_RANGE_combined_exp_pred(d, data) BOOST_PP_TUPLE_ELEM(3, 0, data)
#define BOOST_RANGE_combined_exp_op(d, data) \
( \
BOOST_PP_DEC( \
BOOST_PP_TUPLE_ELEM(3, 0, data) \
), \
BOOST_PP_TUPLE_ELEM(3, 1, data), \
BOOST_PP_MUL_D( \
d, \
BOOST_PP_TUPLE_ELEM(3, 2, data), \
BOOST_PP_TUPLE_ELEM(3, 1, data) \
) \
)
#define BOOST_RANGE_combined_exp(x, n) \
BOOST_PP_TUPLE_ELEM(3, 2, \
BOOST_PP_WHILE(BOOST_RANGE_combined_exp_pred, \
BOOST_RANGE_combined_exp_op, (n, x, 1)))
#define BOOST_RANGE_combined_bitset_pred(n, state) \
BOOST_PP_TUPLE_ELEM(2,1,state)
#define BOOST_RANGE_combined_bitset_op(d, state) \
(BOOST_PP_DIV_D(d, BOOST_PP_TUPLE_ELEM(2,0,state), 2), \
BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(2,1,state)))
#define BOOST_RANGE_combined_bitset(i, n) \
BOOST_PP_MOD(BOOST_PP_TUPLE_ELEM(2, 0, \
BOOST_PP_WHILE(BOOST_RANGE_combined_bitset_pred, \
BOOST_RANGE_combined_bitset_op, (i,n))), 2)
#define BOOST_RANGE_combined_range_iterator(z, n, i) \
typename range_iterator< \
BOOST_PP_CAT(R,n) \
BOOST_PP_IF( \
BOOST_RANGE_combined_bitset(i,n), \
BOOST_PP_IDENTITY(const), \
BOOST_PP_EMPTY)() \
>::type
#define BOOST_RANGE_combined_args(z, n, i) \
BOOST_PP_CAT(R, n) \
BOOST_PP_IF(BOOST_RANGE_combined_bitset(i,n), const&, &) \
BOOST_PP_CAT(r, n)
#define BOOST_RANGE_combine_impl(z, i, n)\
template<BOOST_PP_ENUM_PARAMS(n, typename R)> \
inline range::combined_range< \
boost::tuple<BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, i)> \
> \
combine(BOOST_PP_ENUM(n, BOOST_RANGE_combined_args, i)) \
{ \
typedef tuple< \
BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, i) \
> rng_tuple_t; \
return range::combined_range<rng_tuple_t>( \
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, begin)), \
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, end))); \
}
#define BOOST_RANGE_combine(z, n, data) \
BOOST_PP_REPEAT(BOOST_RANGE_combined_exp(2,n), BOOST_RANGE_combine_impl, n)

View File

@@ -0,0 +1,32 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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/
//
#define BOOST_RANGE_combined_args(z, n, i) \
BOOST_PP_CAT(R, n)&& BOOST_PP_CAT(r, n)
#define BOOST_RANGE_combined_range_iterator(z, n, i) \
typename range_iterator< \
typename remove_reference<BOOST_PP_CAT(R,n)>::type \
>::type
#define BOOST_RANGE_combine(z, n, data) \
template <BOOST_PP_ENUM_PARAMS(n, typename R)> \
inline range::combined_range< \
tuple<BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, ~)> \
> \
combine(BOOST_PP_ENUM(n, BOOST_RANGE_combined_args, ~)) \
{ \
typedef tuple< \
BOOST_PP_ENUM(n, BOOST_RANGE_combined_range_iterator, ~) \
> rng_tuple_t; \
return range::combined_range<rng_tuple_t>( \
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, begin)), \
rng_tuple_t(BOOST_PP_ENUM(n, BOOST_RANGE_combined_seq, end))); \
}

View File

@@ -0,0 +1,116 @@
// 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)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_void.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_ = (is_const_char_ptr_ || is_const_wchar_t_ptr_));
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,81 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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_DEFAULT_CONSTRUCTIBLE_UNARY_FN_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_DEFAULT_CONSTRUCTIBLE_UNARY_FN_HPP_INCLUDED
#include <boost/optional/optional.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/has_trivial_constructor.hpp>
namespace boost
{
namespace range_detail
{
template<typename F, typename R>
class default_constructible_unary_fn_wrapper
{
public:
typedef R result_type;
default_constructible_unary_fn_wrapper()
{
}
default_constructible_unary_fn_wrapper(const F& source)
: m_impl(source)
{
}
default_constructible_unary_fn_wrapper(const default_constructible_unary_fn_wrapper& source)
: m_impl(source.m_impl)
{
}
default_constructible_unary_fn_wrapper& operator=(const default_constructible_unary_fn_wrapper& source)
{
if (source.m_impl)
{
// Lambda are not copy/move assignable.
m_impl.emplace(*source.m_impl);
}
else
{
m_impl.reset();
}
return *this;
}
template<typename Arg>
R operator()(const Arg& arg) const
{
BOOST_ASSERT(m_impl);
return (*m_impl)(arg);
}
template<typename Arg>
R operator()(Arg& arg) const
{
BOOST_ASSERT(m_impl);
return (*m_impl)(arg);
}
private:
boost::optional<F> m_impl;
};
template<typename F, typename R>
struct default_constructible_unary_fn_gen
{
typedef typename boost::mpl::if_<
boost::has_trivial_default_constructor<F>,
F,
default_constructible_unary_fn_wrapper<F,R>
>::type type;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,91 @@
// 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)
//
// Acknowledgements:
// aschoedl supplied a fix to supply the level of interoperability I had
// originally intended, but failed to implement.
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_DEMOTE_ITERATOR_TRAVERSAL_TAG_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_DEMOTE_ITERATOR_TRAVERSAL_TAG_HPP_INCLUDED
#include <boost/iterator/iterator_categories.hpp>
namespace boost
{
namespace range_detail
{
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
struct inner_demote_iterator_traversal_tag
{
};
#define BOOST_DEMOTE_TRAVERSAL_TAG( Tag1, Tag2, ResultTag ) \
template<> struct inner_demote_iterator_traversal_tag< Tag1 , Tag2 > \
{ \
typedef ResultTag type; \
};
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, no_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, incrementable_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, single_pass_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, forward_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, bidirectional_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, random_access_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, no_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, single_pass_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, forward_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, bidirectional_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, random_access_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, no_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, forward_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, bidirectional_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, random_access_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, no_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, forward_traversal_tag, forward_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, bidirectional_traversal_tag, forward_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, random_access_traversal_tag, forward_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, no_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, forward_traversal_tag, forward_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, bidirectional_traversal_tag, bidirectional_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, random_access_traversal_tag, bidirectional_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, no_traversal_tag, no_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, single_pass_traversal_tag, single_pass_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, forward_traversal_tag, forward_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, bidirectional_traversal_tag, bidirectional_traversal_tag )
BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal_tag, random_access_traversal_tag )
#undef BOOST_DEMOTE_TRAVERSAL_TAG
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
struct demote_iterator_traversal_tag
: inner_demote_iterator_traversal_tag<
typename boost::iterators::pure_traversal_tag< IteratorTraversalTag1 >::type,
typename boost::iterators::pure_traversal_tag< IteratorTraversalTag2 >::type
>
{
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,121 @@
// 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_DIFFERENCE_TYPE_HPP
#define BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP
#include <boost/range/detail/common.hpp>
#include <boost/iterator/iterator_traits.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_difference_type_;
template<>
struct range_difference_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
};
};
template<>
struct range_difference_type_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
};
};
template<>
struct range_difference_type_<array_>
{
template< typename A >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
}
template< typename C >
class range_difference
{
typedef BOOST_RANGE_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;
};
}
#endif

View File

@@ -0,0 +1,120 @@
// 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_EMPTY_HPP
#define BOOST_RANGE_DETAIL_EMPTY_HPP
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_empty;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<std_container_>
{
template< typename C >
static bool fun( C& c )
{
return c.empty();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<std_pair_>
{
template< typename P >
static bool fun( const P& p )
{
return p.first == p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<array_>
{
template< typename T, std::size_t sz >
static bool fun( T BOOST_ARRAY_REF[sz] )
{
if( boost_range_array == 0 )
return true;
return false;
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_empty<char_ptr_>
{
static bool fun( const char* s )
{
return s == 0 || s[0] == 0;
}
};
template<>
struct range_empty<const_char_ptr_>
{
static bool fun( const char* s )
{
return s == 0 || s[0] == 0;
}
};
template<>
struct range_empty<wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
return s == 0 || s[0] == 0;
}
};
template<>
struct range_empty<const_wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
return s == 0 || s[0] == 0;
}
};
} // namespace 'range_detail'
template< typename C >
inline bool
empty( const C& c )
{
return range_detail::range_empty< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,48 @@
// 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)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/mpl/has_xxx.hpp>
#if !defined(BOOST_MPL_CFG_NO_HAS_XXX)
// 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 ) \
BOOST_MPL_HAS_XXX_TRAIT_DEF(a_typedef) \
template< typename C, bool B = BOOST_PP_CAT(has_, a_typedef)<C>::value > \
struct BOOST_PP_CAT(extract_, a_typedef) \
{}; \
template< typename C > \
struct BOOST_PP_CAT(extract_, a_typedef)< C, true > \
{ \
typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
};
#else
#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
template< typename C > \
struct BOOST_PP_CAT(extract_, a_typedef) \
{ \
typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
};
#endif
#endif // include guard

View File

@@ -0,0 +1,66 @@
// Boost.Range library
//
// Copyright Neil Groves 2014.
//
// 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_DETAIL_HAS_MEMBER_SIZE_HPP
#define BOOST_RANGE_DETAIL_HAS_MEMBER_SIZE_HPP
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/cstdint.hpp>
namespace boost
{
namespace range_detail
{
template<class T>
class has_member_size_impl
{
private:
template<class U, U>
class check
{
};
template<class C>
static boost::uint8_t f(check<std::size_t(C::*)(void) const, &C::size>*);
template<class C>
static boost::uint16_t f(...);
public:
static const bool value =
(sizeof(f<T>(0)) == sizeof(boost::uint8_t));
typedef typename mpl::if_c<
(sizeof(f<T>(0)) == sizeof(boost::uint8_t)),
mpl::true_,
mpl::false_
>::type type;
};
template<class T>
struct has_member_size
{
typedef typename mpl::and_<
typename is_class<T>::type,
typename has_member_size_impl<const T>::type
>::type type;
static const bool value =
is_class<T>::value && has_member_size_impl<const T>::value;
};
} // namespace range_detail
}// namespace boost
#endif // include guard

View File

@@ -0,0 +1,114 @@
// 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 >
BOOST_CONSTEXPR inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] ) BOOST_NOEXCEPT
{
return boost_range_array + sz;
}
template< class T, std::size_t sz >
BOOST_CONSTEXPR inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] ) BOOST_NOEXCEPT
{
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;
}
inline bool is_same_address(const void* l, const void* r)
{
return l == r;
}
template<class T1, class T2>
inline bool is_same_object(const T1& l, const T2& r)
{
return range_detail::is_same_address(&l, &r);
}
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,358 @@
// 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)
//
// Acknowledgements:
// aschoedl contributed an improvement to the determination
// of the Reference type parameter.
//
// Leonid Gershanovich reported Trac ticket 7376 about the dereference operator
// requiring identical reference types due to using the ternary if.
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED
#include <iterator>
#include <boost/assert.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/empty.hpp>
#include <boost/range/detail/demote_iterator_traversal_tag.hpp>
#include <boost/range/value_type.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/next_prior.hpp>
namespace boost
{
namespace range_detail
{
template<typename Iterator1, typename Iterator2>
struct join_iterator_link
{
public:
join_iterator_link(Iterator1 last1, Iterator2 first2)
: last1(last1)
, first2(first2)
{
}
Iterator1 last1;
Iterator2 first2;
private:
join_iterator_link() /* = delete */ ;
};
class join_iterator_begin_tag {};
class join_iterator_end_tag {};
template<typename Iterator1
, typename Iterator2
, typename Reference
>
class join_iterator_union
{
public:
typedef Iterator1 iterator1_t;
typedef Iterator2 iterator2_t;
join_iterator_union() {}
join_iterator_union(unsigned int /*selected*/, const iterator1_t& it1, const iterator2_t& it2) : m_it1(it1), m_it2(it2) {}
iterator1_t& it1() { return m_it1; }
const iterator1_t& it1() const { return m_it1; }
iterator2_t& it2() { return m_it2; }
const iterator2_t& it2() const { return m_it2; }
Reference dereference(unsigned int selected) const
{
if (selected)
return *m_it2;
return *m_it1;
}
bool equal(const join_iterator_union& other, unsigned int selected) const
{
return selected
? m_it2 == other.m_it2
: m_it1 == other.m_it1;
}
private:
iterator1_t m_it1;
iterator2_t m_it2;
};
template<class Iterator, class Reference>
class join_iterator_union<Iterator, Iterator, Reference>
{
public:
typedef Iterator iterator1_t;
typedef Iterator iterator2_t;
join_iterator_union() {}
join_iterator_union(unsigned int selected, const iterator1_t& it1, const iterator2_t& it2)
: m_it(selected ? it2 : it1)
{
}
iterator1_t& it1() { return m_it; }
const iterator1_t& it1() const { return m_it; }
iterator2_t& it2() { return m_it; }
const iterator2_t& it2() const { return m_it; }
Reference dereference(unsigned int) const
{
return *m_it;
}
bool equal(const join_iterator_union& other,
unsigned int /*selected*/) const
{
return m_it == other.m_it;
}
private:
iterator1_t m_it;
};
template<typename Iterator1
, typename Iterator2
, typename ValueType = typename iterator_value<Iterator1>::type
// find least demanding, commonly supported reference type, in the order &, const&, and by-value:
, typename Reference = typename mpl::if_c<
!is_reference<typename iterator_reference<Iterator1>::type>::value
|| !is_reference<typename iterator_reference<Iterator2>::type>::value,
typename remove_const<
typename remove_reference<
typename iterator_reference<Iterator1>::type
>::type
>::type,
typename mpl::if_c<
is_const<
typename remove_reference<
typename iterator_reference<Iterator1>::type
>::type
>::value
|| is_const<
typename remove_reference<
typename iterator_reference<Iterator2>::type
>::type
>::value,
typename add_reference<
typename add_const<
typename remove_reference<
typename iterator_reference<Iterator1>::type
>::type
>::type
>::type,
typename iterator_reference<Iterator1>::type
>::type
>::type
, typename Traversal = typename demote_iterator_traversal_tag<
typename iterator_traversal<Iterator1>::type
, typename iterator_traversal<Iterator2>::type>::type
>
class join_iterator
: public iterator_facade<join_iterator<Iterator1,Iterator2,ValueType,Reference,Traversal>, ValueType, Traversal, Reference>
{
typedef join_iterator_link<Iterator1, Iterator2> link_t;
typedef join_iterator_union<Iterator1, Iterator2, Reference> iterator_union;
public:
typedef Iterator1 iterator1_t;
typedef Iterator2 iterator2_t;
join_iterator()
: m_section(0u)
, m_it(0u, iterator1_t(), iterator2_t())
, m_link(link_t(iterator1_t(), iterator2_t()))
{}
join_iterator(unsigned int section, Iterator1 current1, Iterator1 last1, Iterator2 first2, Iterator2 current2)
: m_section(section)
, m_it(section, current1, current2)
, m_link(link_t(last1, first2))
{
}
template<typename Range1, typename Range2>
join_iterator(Range1& r1, Range2& r2, join_iterator_begin_tag)
: m_section(boost::empty(r1) ? 1u : 0u)
, m_it(boost::empty(r1) ? 1u : 0u, boost::begin(r1), boost::begin(r2))
, m_link(link_t(boost::end(r1), boost::begin(r2)))
{
}
template<typename Range1, typename Range2>
join_iterator(const Range1& r1, const Range2& r2, join_iterator_begin_tag)
: m_section(boost::empty(r1) ? 1u : 0u)
, m_it(boost::empty(r1) ? 1u : 0u, boost::const_begin(r1), boost::const_begin(r2))
, m_link(link_t(boost::const_end(r1), boost::const_begin(r2)))
{
}
template<typename Range1, typename Range2>
join_iterator(Range1& r1, Range2& r2, join_iterator_end_tag)
: m_section(1u)
, m_it(1u, boost::end(r1), boost::end(r2))
, m_link(link_t(boost::end(r1), boost::begin(r2)))
{
}
template<typename Range1, typename Range2>
join_iterator(const Range1& r1, const Range2& r2, join_iterator_end_tag)
: m_section(1u)
, m_it(1u, boost::const_end(r1), boost::const_end(r2))
, m_link(link_t(boost::const_end(r1), boost::const_begin(r2)))
{
}
private:
void increment()
{
if (m_section)
++m_it.it2();
else
{
++m_it.it1();
if (m_it.it1() == m_link.last1)
{
m_it.it2() = m_link.first2;
m_section = 1u;
}
}
}
void decrement()
{
if (m_section)
{
if (m_it.it2() == m_link.first2)
{
m_it.it1() = boost::prior(m_link.last1);
m_section = 0u;
}
else
--m_it.it2();
}
else
--m_it.it1();
}
typename join_iterator::reference dereference() const
{
return m_it.dereference(m_section);
}
bool equal(const join_iterator& other) const
{
return m_section == other.m_section
&& m_it.equal(other.m_it, m_section);
}
void advance(typename join_iterator::difference_type offset)
{
if (m_section)
advance_from_range2(offset);
else
advance_from_range1(offset);
}
typename join_iterator::difference_type distance_to(const join_iterator& other) const
{
typename join_iterator::difference_type result;
if (m_section)
{
if (other.m_section)
result = other.m_it.it2() - m_it.it2();
else
{
result = (m_link.first2 - m_it.it2())
+ (other.m_it.it1() - m_link.last1);
BOOST_ASSERT( result <= 0 );
}
}
else
{
if (other.m_section)
{
result = (m_link.last1 - m_it.it1())
+ (other.m_it.it2() - m_link.first2);
}
else
result = other.m_it.it1() - m_it.it1();
}
return result;
}
void advance_from_range2(typename join_iterator::difference_type offset)
{
typedef typename join_iterator::difference_type difference_t;
BOOST_ASSERT( m_section == 1u );
if (offset < 0)
{
difference_t r2_dist = m_link.first2 - m_it.it2();
BOOST_ASSERT( r2_dist <= 0 );
if (offset >= r2_dist)
std::advance(m_it.it2(), offset);
else
{
difference_t r1_dist = offset - r2_dist;
BOOST_ASSERT( r1_dist <= 0 );
m_it.it1() = m_link.last1 + r1_dist;
m_section = 0u;
}
}
else
std::advance(m_it.it2(), offset);
}
void advance_from_range1(typename join_iterator::difference_type offset)
{
typedef typename join_iterator::difference_type difference_t;
BOOST_ASSERT( m_section == 0u );
if (offset > 0)
{
difference_t r1_dist = m_link.last1 - m_it.it1();
BOOST_ASSERT( r1_dist >= 0 );
if (offset < r1_dist)
std::advance(m_it.it1(), offset);
else
{
difference_t r2_dist = offset - r1_dist;
BOOST_ASSERT( r2_dist >= 0 );
m_it.it2() = m_link.first2 + r2_dist;
m_section = 1u;
}
}
else
std::advance(m_it.it1(), offset);
}
unsigned int m_section;
iterator_union m_it;
link_t m_link;
friend class ::boost::iterator_core_access;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,26 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_RANGE_DETAIL_LESS
#define BOOST_RANGE_DETAIL_LESS
namespace boost {
namespace range {
namespace detail {
struct less {
template<class T, class U>
bool operator()(const T& lhs, const U& rhs) const {
return lhs < rhs;
}
};
} /* detail */
} /* range */
} /* boost */
#endif

View File

@@ -0,0 +1,932 @@
#ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP
#define BOOST_RANGE_DETAIL_MICROSOFT_HPP
// Boost.Range MFC/ATL Extension
//
// Copyright Shunsuke Sogame 2005-2006.
// 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)
// config
//
#include <boost/range/iterator.hpp>
#define BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1 1
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
#define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin
#define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end
#else
#define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
#define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin
#define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end
#endif
// yet another customization way
//
#include <boost/iterator/iterator_traits.hpp> // iterator_difference
#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/detail/is_unary.hpp>
#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/size_type.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/utility/enable_if.hpp> // disable_if
#include <boost/next_prior.hpp>
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#include <boost/range/mutable_iterator.hpp>
#else
#include <iterator> // distance
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>
#endif
namespace boost { namespace range_detail_microsoft {
// customization point
//
template< class Tag >
struct customization;
template< class T >
struct customization_tag;
struct using_type_as_tag
{ };
// Topic:
// In fact, it is unnecessary for VC++.
// VC++'s behavior seems conforming, while GCC fails without this.
template< class Iterator, class T >
struct mutable_ :
disable_if< is_const<T>, Iterator >
{ };
// helpers
//
template< class Tag, class T >
struct customization_tag_of
{
typedef typename mpl::if_< is_same<using_type_as_tag, Tag>,
T,
Tag
>::type type;
};
template< class T >
struct customization_of
{
typedef typename remove_cv<T>::type bare_t;
typedef typename customization_tag<bare_t>::type tag_t;
typedef customization<tag_t> type;
};
template< class T >
struct mutable_iterator_of
{
typedef typename remove_cv<T>::type bare_t;
typedef typename customization_of<bare_t>::type cust_t;
typedef typename cust_t::template meta<bare_t>::mutable_iterator type;
};
template< class T >
struct const_iterator_of
{
typedef typename remove_cv<T>::type bare_t;
typedef typename customization_of<bare_t>::type cust_t;
typedef typename cust_t::template meta<bare_t>::const_iterator type;
};
template< class T >
struct size_type_of
{
typedef typename range_detail_microsoft::mutable_iterator_of<T>::type miter_t;
typedef typename iterator_difference<miter_t>::type type;
};
template< class T > inline
typename mutable_iterator_of<T>::type
begin_of(T& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template begin<typename mutable_iterator_of<T>::type>(x);
}
template< class T > inline
typename const_iterator_of<T>::type
begin_of(T const& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template begin<typename const_iterator_of<T>::type>(x);
}
template< class T > inline
typename mutable_iterator_of<T>::type
end_of(T& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template end<typename mutable_iterator_of<T>::type>(x);
}
template< class T > inline
typename const_iterator_of<T>::type
end_of(T const& x)
{
typedef typename customization_of<T>::type cust_t;
return cust_t().template end<typename const_iterator_of<T>::type>(x);
}
#if defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
template< class T > inline
typename size_type_of<T>::type
size_of(T const& x)
{
return std::distance(boost::begin(x), boost::end(x));
}
#endif
template< class Range >
struct compatible_mutable_iterator :
BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>
{ };
} } // namespace boost::range_detail_microsoft
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op, ~, NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op(r, data, elem) \
namespace elem { \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op, ~, NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op(r, data, elem) \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op(r, data, elem) \
:: elem \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(Tag, NamespaceList, Name) \
namespace boost { namespace range_detail_microsoft { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
} } \
\
namespace boost { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
} \
\
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) :: Name \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, Fullname) \
template< > \
struct customization_tag< Fullname > : \
customization_tag_of< Tag, Fullname > \
{ }; \
/**/
// metafunctions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(Fullname) \
template< > \
struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
range_detail_microsoft::mutable_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(Fullname) \
template< > \
struct range_const_iterator< Fullname > : \
range_detail_microsoft::const_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(Fullname) \
template< > \
struct range_size< Fullname > : \
range_detail_microsoft::size_type_of< Fullname > \
{ }; \
/**/
// functions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(Fullname) \
inline \
boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(Fullname) \
inline \
boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(Fullname) \
inline \
boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(Fullname) \
inline \
boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
/**/
#else
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
inline \
boost::range_detail_microsoft::size_type_of< Fullname >::type \
boost_range_size(Fullname const& x) \
{ \
return boost::range_detail_microsoft::size_of(x); \
} \
/**/
#endif
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(Tag, NamespaceList, Name, ParamSeqOrCount) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl( \
Tag, NamespaceList, Name, \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
BOOST_PP_IIF(BOOST_PP_IS_UNARY(ParamSeqOrCount), \
ParamSeqOrCount BOOST_PP_TUPLE_EAT(3), \
BOOST_PP_REPEAT \
)(ParamSeqOrCount, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op, ~) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op(z, n, _) \
(class) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl(Tag, NamespaceList, Name, ParamSeq) \
namespace boost { namespace range_detail_microsoft { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag( \
Tag, \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
} } \
\
namespace boost { \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
\
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
} \
\
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size( \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
) \
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq) \
BOOST_PP_SEQ_FOR_EACH_I(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op, ~, ParamSeq) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op(r, data, i, elem) \
BOOST_PP_COMMA_IF(i) elem BOOST_PP_CAT(T, i) \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) \
:: Name < BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(ParamSeq), T) > \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag(Tag, Params, Fullname) \
template< Params > \
struct customization_tag< Fullname > : \
customization_tag_of< Tag, Fullname > \
{ }; \
/**/
// metafunctions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator(Params, Fullname) \
template< Params > \
struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
range_detail_microsoft::mutable_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator(Params, Fullname) \
template< Params > \
struct range_const_iterator< Fullname > : \
range_detail_microsoft::const_iterator_of< Fullname > \
{ }; \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type(Params, Fullname) \
template< Params > \
struct range_size< Fullname > : \
range_detail_microsoft::size_type_of< Fullname > \
{ }; \
/**/
// functions
//
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
{ \
return boost::range_detail_microsoft::begin_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
{ \
return boost::range_detail_microsoft::end_of(x); \
} \
/**/
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
/**/
#else
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
template< Params > inline \
typename boost::range_detail_microsoft::size_type_of< Fullname >::type \
boost_range_size(Fullname const& x) \
{ \
return boost::range_detail_microsoft::size_of(x); \
} \
/**/
#endif
// list_iterator and helpers
//
#include <boost/assert.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
// POSITION's header is undocumented, so is NULL.
//
struct __POSITION; // incomplete, but used as just a pointer.
typedef __POSITION *POSITION;
namespace boost { namespace range_detail_microsoft {
template<
class ListT,
class Value,
class Reference,
class Traversal
>
struct list_iterator;
template<
class ListT,
class Value,
class Reference,
class Traversal
>
struct list_iterator_super
{
typedef typename mpl::if_< is_same<use_default, Reference>,
Value&,
Reference
>::type ref_t;
typedef typename mpl::if_< is_same<use_default, Traversal>,
bidirectional_traversal_tag,
Traversal
>::type trv_t;
typedef iterator_facade<
list_iterator<ListT, Value, Reference, Traversal>,
Value,
trv_t,
ref_t
> type;
};
template<
class ListT,
class Value,
class Reference = use_default,
class Traversal = use_default
>
struct list_iterator :
list_iterator_super<ListT, Value, Reference, Traversal>::type
{
private:
typedef list_iterator self_t;
typedef typename list_iterator_super<ListT, Value, Reference, Traversal>::type super_t;
typedef typename super_t::reference ref_t;
public:
explicit list_iterator()
{ }
explicit list_iterator(ListT& lst, POSITION pos) :
m_plst(boost::addressof(lst)), m_pos(pos)
{ }
template< class, class, class, class > friend struct list_iterator;
template< class ListT_, class Value_, class Reference_, class Traversal_>
list_iterator(list_iterator<ListT_, Value_, Reference_, Traversal_> const& other) :
m_plst(other.m_plst), m_pos(other.m_pos)
{ }
private:
ListT *m_plst;
POSITION m_pos;
friend class iterator_core_access;
ref_t dereference() const
{
BOOST_ASSERT(m_pos != 0 && "out of range");
return m_plst->GetAt(m_pos);
}
// A B C D x
// Head Tail NULL(0)
//
void increment()
{
BOOST_ASSERT(m_pos != 0 && "out of range");
m_plst->GetNext(m_pos);
}
void decrement()
{
if (m_pos == 0) {
m_pos = m_plst->GetTailPosition();
return;
}
m_plst->GetPrev(m_pos);
}
bool equal(self_t const& other) const
{
BOOST_ASSERT(m_plst == other.m_plst && "iterators incompatible");
return m_pos == other.m_pos;
}
};
// customization helpers
//
struct array_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
return x.GetData();
}
template< class Iterator, class X >
Iterator end(X& x)
{
return begin<Iterator>(x) + x.GetSize();
}
};
struct list_functions
{
template< class Iterator, class X >
Iterator begin(X& x)
{
return Iterator(x, x.GetHeadPosition());
}
template< class Iterator, class X >
Iterator end(X& x)
{
return Iterator(x, POSITION(0));
}
};
} } // namespace boost::range_detail_microsoft
// test
//
#if defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
#include <algorithm>
#include <iterator>
#include <vector>
#include <boost/concept_check.hpp>
#include <boost/next_prior.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/distance.hpp>
#include <boost/range/empty.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/mutable_iterator.hpp>
#include <boost/range/rbegin.hpp>
#include <boost/range/rend.hpp>
#include <boost/range/value_type.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace range_detail_microsoft {
template< class Range1, class Range2 >
bool test_equals(Range1 const& rng1, Range2 const& rng2)
{
return
boost::distance(rng1) == boost::distance(rng2) &&
std::equal(boost::begin(rng1), boost::end(rng1), boost::begin(rng2))
;
}
template< class AssocContainer, class PairT >
bool test_find_key_and_mapped(AssocContainer const& ac, PairT const& pa)
{
typedef typename boost::range_const_iterator<AssocContainer>::type iter_t;
for (iter_t it = boost::const_begin(ac), last = boost::const_end(ac); it != last; ++it) {
if (it->first == pa.first && it->second == pa.second)
return true;
}
return false;
}
// test functions
//
template< class Range >
bool test_emptiness(Range& )
{
bool result = true;
Range emptyRng;
result = result && boost::empty(emptyRng);
return result;
}
template< class Range >
bool test_trivial(Range& rng)
{
bool result = true;
// convertibility check
typedef typename range_const_iterator<Range>::type citer_t;
citer_t cit = boost::begin(rng);
(void)cit; // unused
// mutability check
typedef typename range_value<Range>::type val_t;
val_t v = *boost::begin(rng);
*boost::begin(rng) = v;
result = result && *boost::begin(rng) == v;
return result;
}
template< class Range >
bool test_forward(Range& rng)
{
boost::function_requires< ForwardRangeConcept<Range> >();
bool result = (test_trivial)(rng);
typedef typename range_value<Range>::type val_t;
std::vector<val_t> saved;
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
std::rotate(boost::begin(saved), boost::next(boost::begin(saved)), boost::end(saved));
std::rotate(boost::begin(rng), boost::next(boost::begin(rng)), boost::end(rng));
return result && (test_equals)(saved, rng);
};
template< class Range >
bool test_bidirectional(Range& rng)
{
boost::function_requires< BidirectionalRangeConcept<Range> >();
bool result = (test_forward)(rng);
typedef typename range_value<Range>::type val_t;
std::vector<val_t> saved;
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
result = result && (test_equals)(
boost::make_iterator_range(boost::rbegin(saved), boost::rend(saved)),
boost::make_iterator_range(boost::rbegin(rng), boost::rend(rng))
);
return result;
}
template< class Range >
bool test_random_access(Range& rng)
{
boost::function_requires< RandomAccessRangeConcept<Range> >();
bool result = (test_bidirectional)(rng);
typedef typename range_value<Range>::type val_t;
std::vector<val_t> saved;
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
std::sort(boost::begin(saved), boost::end(saved));
std::random_shuffle(boost::begin(rng), boost::end(rng));
std::sort(boost::begin(rng), boost::end(rng));
result = result && (test_equals)(rng, saved);
std::random_shuffle(boost::begin(rng), boost::end(rng));
std::stable_sort(boost::begin(rng), boost::end(rng));
result = result && (test_equals)(rng, saved);
std::random_shuffle(boost::begin(rng), boost::end(rng));
std::partial_sort(boost::begin(rng), boost::end(rng), boost::end(rng));
result = result && (test_equals)(rng, saved);
return result;
}
// initializer
//
template< class ArrayT, class SampleRange >
bool test_init_array(ArrayT& arr, SampleRange const& sample)
{
typedef typename range_const_iterator<SampleRange>::type iter_t;
typedef typename range_value<SampleRange>::type val_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
val_t v = *it; // works around ATL3 CSimpleArray
arr.Add(v);
}
return (test_equals)(arr, sample);
}
template< class ListT, class SampleRange >
bool test_init_list(ListT& lst, SampleRange const& sample)
{
typedef typename range_const_iterator<SampleRange>::type iter_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
lst.AddTail(*it);
}
return (test_equals)(lst, sample);
}
template< class StringT, class SampleRange >
bool test_init_string(StringT& str, SampleRange const& sample)
{
typedef typename range_const_iterator<SampleRange>::type iter_t;
typedef typename range_value<SampleRange>::type val_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
str += *it;
}
return (test_equals)(str, sample);
}
template< class MapT, class SampleMap >
bool test_init_map(MapT& map, SampleMap const& sample)
{
typedef typename range_const_iterator<SampleMap>::type iter_t;
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
map.SetAt(it->first, it->second);
}
return boost::distance(map) == boost::distance(sample);
}
// metafunction test
//
template< class Range, class Iter >
struct test_mutable_iter :
boost::is_same< typename boost::BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>::type, Iter >
{ };
template< class Range, class Iter >
struct test_const_iter :
boost::is_same< typename boost::range_const_iterator<Range>::type, Iter >
{ };
} } // namespace boost::range_detail_microsoft
#endif // defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
#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,132 @@
// Boost.Range library
//
// Copyright Eric Niebler 2014. 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_MSVC_HAS_ITERATOR_WORKAROUND_HPP
#define BOOST_RANGE_DETAIL_MSVC_HAS_ITERATOR_WORKAROUND_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#ifndef BOOST_RANGE_MUTABLE_ITERATOR_HPP
# error This file should only be included from <boost/range/mutable_iterator.hpp>
#endif
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1600)
namespace boost
{
namespace cb_details
{
template <class Buff, class Traits>
struct iterator;
}
namespace python
{
template <class Container
, class NextPolicies /*= objects::default_iterator_call_policies*/>
struct iterator;
}
namespace type_erasure
{
template<
class Traversal,
class T /*= _self*/,
class Reference /*= ::boost::use_default*/,
class DifferenceType /*= ::std::ptrdiff_t*/,
class ValueType /*= typename deduced<iterator_value_type<T> >::type*/
>
struct iterator;
}
namespace unordered { namespace iterator_detail
{
template <typename Node>
struct iterator;
}}
namespace container { namespace container_detail
{
template<class IIterator, bool IsConst>
class iterator;
}}
namespace spirit { namespace lex { namespace lexertl
{
template <typename Functor>
class iterator;
}}}
namespace range_detail
{
template <class Buff, class Traits>
struct has_iterator< ::boost::cb_details::iterator<Buff, Traits> >
: mpl::false_
{};
template <class Buff, class Traits>
struct has_iterator< ::boost::cb_details::iterator<Buff, Traits> const>
: mpl::false_
{};
template <class Container, class NextPolicies>
struct has_iterator< ::boost::python::iterator<Container, NextPolicies> >
: mpl::false_
{};
template <class Container, class NextPolicies>
struct has_iterator< ::boost::python::iterator<Container, NextPolicies> const>
: mpl::false_
{};
template<class Traversal, class T, class Reference, class DifferenceType, class ValueType>
struct has_iterator< ::boost::type_erasure::iterator<Traversal, T, Reference, DifferenceType, ValueType> >
: mpl::false_
{};
template<class Traversal, class T, class Reference, class DifferenceType, class ValueType>
struct has_iterator< ::boost::type_erasure::iterator<Traversal, T, Reference, DifferenceType, ValueType> const>
: mpl::false_
{};
template <typename Node>
struct has_iterator< ::boost::unordered::iterator_detail::iterator<Node> >
: mpl::false_
{};
template <typename Node>
struct has_iterator< ::boost::unordered::iterator_detail::iterator<Node> const>
: mpl::false_
{};
template<class IIterator, bool IsConst>
struct has_iterator< ::boost::container::container_detail::iterator<IIterator, IsConst> >
: mpl::false_
{};
template<class IIterator, bool IsConst>
struct has_iterator< ::boost::container::container_detail::iterator<IIterator, IsConst> const>
: mpl::false_
{};
template <typename Functor>
struct has_iterator< ::boost::spirit::lex::lexertl::iterator<Functor> >
: mpl::false_
{};
template <typename Functor>
struct has_iterator< ::boost::spirit::lex::lexertl::iterator<Functor> const>
: mpl::false_
{};
}
}
#endif
#endif

View File

@@ -0,0 +1,181 @@
// 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_DETAIL_RANGE_RETURN_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_RANGE_RETURN_HPP_INCLUDED
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/next_prior.hpp>
namespace boost
{
enum range_return_value
{
// (*) indicates the most common values
return_found, // only the found resulting iterator (*)
return_next, // next(found) iterator
return_prior, // prior(found) iterator
return_begin_found, // [begin, found) range (*)
return_begin_next, // [begin, next(found)) range
return_begin_prior, // [begin, prior(found)) range
return_found_end, // [found, end) range (*)
return_next_end, // [next(found), end) range
return_prior_end, // [prior(found), end) range
return_begin_end // [begin, end) range
};
template< class SinglePassRange, range_return_value >
struct range_return
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
SinglePassRange& rng)
{
return type(found, boost::end(rng));
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_found >
{
typedef BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type type;
static type pack(type found, SinglePassRange&)
{
return found;
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_next >
{
typedef BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type type;
static type pack(type found, SinglePassRange& rng)
{
return found == boost::end(rng)
? found
: boost::next(found);
}
};
template< class BidirectionalRange >
struct range_return< BidirectionalRange, return_prior >
{
typedef BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type type;
static type pack(type found, BidirectionalRange& rng)
{
return found == boost::begin(rng)
? found
: boost::prior(found);
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_begin_found >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
SinglePassRange& rng)
{
return type(boost::begin(rng), found);
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_begin_next >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
SinglePassRange& rng)
{
return type( boost::begin(rng),
found == boost::end(rng) ? found : boost::next(found) );
}
};
template< class BidirectionalRange >
struct range_return< BidirectionalRange, return_begin_prior >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type found,
BidirectionalRange& rng)
{
return type( boost::begin(rng),
found == boost::begin(rng) ? found : boost::prior(found) );
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_found_end >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
SinglePassRange& rng)
{
return type(found, boost::end(rng));
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_next_end >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
SinglePassRange& rng)
{
return type( found == boost::end(rng) ? found : boost::next(found),
boost::end(rng) );
}
};
template< class BidirectionalRange >
struct range_return< BidirectionalRange, return_prior_end >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type found,
BidirectionalRange& rng)
{
return type( found == boost::begin(rng) ? found : boost::prior(found),
boost::end(rng) );
}
};
template< class SinglePassRange >
struct range_return< SinglePassRange, return_begin_end >
{
typedef boost::iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type,
SinglePassRange& rng)
{
return type(boost::begin(rng), boost::end(rng));
}
};
}
#endif // include guard

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,35 @@
// 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_SIZER_HPP
#define BOOST_RANGE_DETAIL_SIZER_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <cstddef>
namespace boost
{
//////////////////////////////////////////////////////////////////////
// constant array size
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
char (& sizer( const T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz];
template< typename T, std::size_t sz >
char (& sizer( T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz];
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,38 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 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_DETAIL_STR_TYPES_HPP
#define BOOST_RANGE_DETAIL_STR_TYPES_HPP
#include <boost/range/size_type.hpp>
#include <boost/range/iterator.hpp>
namespace boost
{
template< class T >
struct range_mutable_iterator<T*>
{
typedef T* type;
};
template< class T >
struct range_const_iterator<T*>
{
typedef const T* type;
};
template< class T >
struct range_size<T*>
{
typedef std::size_t type;
};
}
#endif