Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,587 @@
// 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/cast.hpp>
#include <boost/utility.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/not.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>
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 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 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 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 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 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 impementation 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/utility.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,258 @@
// 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/type_traits/add_reference.hpp>
#include <boost/type_traits/add_const.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_reference<
typename add_const<
typename remove_reference<T>::type
>::type
>::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 remove_const<
typename remove_reference<Reference>::type
>::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,590 @@
// 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/range/config.hpp>
#include <boost/range/detail/any_iterator_interface.hpp>
namespace boost
{
namespace range_detail
{
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> ));
public:
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 == boost::polymorphic_downcast<const any_single_pass_iterator_wrapper*>(&other)->m_it;
}
virtual Reference dereference() const
{
return *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> ));
public:
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 == boost::polymorphic_downcast<const any_forward_iterator_wrapper*>(&other)->m_it;
}
virtual Reference dereference() const
{
return *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> ));
public:
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 == boost::polymorphic_downcast<const any_bidirectional_iterator_wrapper*>(&other)->m_it;
}
virtual Reference dereference() const
{
return *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> ));
public:
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 == boost::polymorphic_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 *m_it;
}
virtual Difference distance_to(const any_random_access_iterator_interface<Reference, Difference, Buffer>& other) const
{
return boost::polymorphic_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,33 @@
// 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_AS_LITERAL_HPP
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/detail/detail_str.hpp>
#include <boost/range/iterator_range.hpp>
namespace boost
{
template< class Range >
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
as_literal( Range& r )
{
return ::boost::make_iterator_range( ::boost::range_detail::str_begin(r),
::boost::range_detail::str_end(r) );
}
}
#endif

View File

@@ -0,0 +1,94 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
#define BOOST_RANGE_DETAIL_BEGIN_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/detail/common.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/value_type.hpp>
#endif
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_begin;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
{
return c.begin();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
{
return p.first;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost_range_array;
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
{
return t;
}
#endif
};
} // namespace 'range_detail'
namespace range_adl_barrier
{
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
}
} // namespace 'boost'
#endif

View File

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

View File

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

View File

@@ -0,0 +1,117 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_COMMON_HPP
#define BOOST_RANGE_DETAIL_COMMON_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <cstddef>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
// 1 = std containers
// 2 = std::pair
// 3 = const std::pair
// 4 = array
// 5 = const array
// 6 = char array
// 7 = wchar_t array
// 8 = char*
// 9 = const char*
// 10 = whar_t*
// 11 = const wchar_t*
// 12 = string
typedef mpl::int_<1>::type std_container_;
typedef mpl::int_<2>::type std_pair_;
typedef mpl::int_<3>::type const_std_pair_;
typedef mpl::int_<4>::type array_;
typedef mpl::int_<5>::type const_array_;
typedef mpl::int_<6>::type char_array_;
typedef mpl::int_<7>::type wchar_t_array_;
typedef mpl::int_<8>::type char_ptr_;
typedef mpl::int_<9>::type const_char_ptr_;
typedef mpl::int_<10>::type wchar_t_ptr_;
typedef mpl::int_<11>::type const_wchar_t_ptr_;
typedef mpl::int_<12>::type string_;
template< typename C >
struct range_helper
{
static C* c;
static C ptr;
BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::value ));
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
};
template< typename C >
class range
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
boost::range_detail::std_pair_,
void >::type pair_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
boost::range_detail::array_,
pair_t >::type array_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
boost::range_detail::string_,
array_t >::type string_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
boost::range_detail::const_char_ptr_,
string_t >::type const_char_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
boost::range_detail::char_ptr_,
const_char_ptr_t >::type char_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
boost::range_detail::const_wchar_t_ptr_,
char_ptr_t >::type const_wchar_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
boost::range_detail::wchar_t_ptr_,
const_wchar_ptr_t >::type wchar_ptr_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
boost::range_detail::wchar_t_array_,
wchar_ptr_t >::type wchar_array_t;
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
boost::range_detail::char_array_,
wchar_array_t >::type char_array_t;
public:
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
boost::range_detail::std_container_,
char_array_t >::type type;
}; // class 'range'
}
}
#endif

View File

@@ -0,0 +1,71 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_const_iterator_;
template<>
struct range_const_iterator_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::const_iterator type;
};
};
template<>
struct range_const_iterator_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_const_iterator_<array_>
{
template< typename T >
struct pts
{
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
}
template< typename C >
class range_const_iterator
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_const_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@@ -0,0 +1,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::detail::pure_traversal_tag< IteratorTraversalTag1 >::type,
typename boost::detail::pure_traversal_tag< IteratorTraversalTag2 >::type
>
{
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,376 @@
// 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_DETAIL_STR_HPP
#define BOOST_RANGE_DETAIL_DETAIL_STR_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/range/iterator.hpp>
namespace boost
{
namespace range_detail
{
//
// iterator
//
template<>
struct range_iterator_<char_array_>
{
template< typename T >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_iterator_<char_ptr_>
{
template< typename S >
struct pts
{
typedef char* type;
};
};
template<>
struct range_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t* type;
};
};
template<>
struct range_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
//
// const iterator
//
template<>
struct range_const_iterator_<char_array_>
{
template< typename T >
struct pts
{
typedef const BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
template<>
struct range_const_iterator_<char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
template<>
struct range_const_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
}
}
#include <boost/range/detail/begin.hpp>
#include <boost/range/detail/end.hpp>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/value_type.hpp>
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
//
// str_begin()
//
template<>
struct range_begin<char_ptr_>
{
static char* fun( char* s )
{
return s;
}
};
template<>
struct range_begin<const_char_ptr_>
{
static const char* fun( const char* s )
{
return s;
}
};
template<>
struct range_begin<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return s;
}
};
template<>
struct range_begin<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return s;
}
};
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
str_begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME
range_detail::range<C>::type >::fun( c );
}
//
// str_end()
//
template<>
struct range_end<char_array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( boost_range_array );
}
};
template<>
struct range_end<wchar_t_array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( boost_range_array );
}
};
template<>
struct range_end<char_ptr_>
{
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct range_end<const_char_ptr_>
{
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct range_end<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct range_end<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
str_end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME
range_detail::range<C>::type >::fun( c );
}
//
// size_type
//
template<>
struct range_size_type_<char_array_>
{
template< typename A >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
//
// value_type
//
template<>
struct range_value_type_<char_array_>
{
template< typename T >
struct pts
{
typedef char type;
};
};
template<>
struct range_value_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef char type;
};
};
template<>
struct range_value_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char type;
};
};
template<>
struct range_value_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t type;
};
};
template<>
struct range_value_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t type;
};
};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

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

101
test/external/boost/range/detail/end.hpp vendored Normal file
View File

@@ -0,0 +1,101 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_END_HPP
#define BOOST_RANGE_DETAIL_END_HPP
#include <boost/config.hpp> // BOOST_MSVC
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# include <boost/range/detail/vc6/end.hpp>
#else
# include <boost/range/detail/implementation_help.hpp>
# include <boost/range/iterator.hpp>
# include <boost/range/detail/common.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
# include <boost/range/detail/remove_extent.hpp>
# endif
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
fun( C& c )
{
return c.end();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
fun( const P& p )
{
return p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost::range_detail::array_end( boost_range_array );
}
#else
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
{
return t + remove_extent<T>::size;
}
#endif
};
} // namespace 'range_detail'
namespace range_adl_barrier
{
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace range_adl_barrier
} // namespace 'boost'
# endif // VC6
#endif

View File

@@ -0,0 +1,52 @@
// Boost.Range library
//
// Copyright Arno Schoedl & Neil Groves 2009.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/config.hpp>
#ifdef BOOST_NO_PARTIAL_TEMPLATE_SPECIALIZATION
#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
template< typename C > \
struct extract_ ## a_typedef \
{ \
typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
};
#else
namespace boost {
namespace range_detail {
template< typename T > struct exists { typedef void type; };
}
}
// Defines extract_some_typedef<T> which exposes T::some_typedef as
// extract_some_typedef<T>::type if T::some_typedef exists. Otherwise
// extract_some_typedef<T> is empty.
#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
template< typename C, typename Enable=void > \
struct extract_ ## a_typedef \
{}; \
template< typename C > \
struct extract_ ## a_typedef< C \
, BOOST_DEDUCED_TYPENAME boost::range_detail::exists< BOOST_DEDUCED_TYPENAME C::a_typedef >::type \
> { \
typedef BOOST_DEDUCED_TYPENAME C::a_typedef type; \
};
#endif
#endif // include guard

View File

@@ -0,0 +1,103 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
#define BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
#include <boost/range/config.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/type_traits/is_same.hpp>
#include <cstddef>
#include <string.h>
#ifndef BOOST_NO_CWCHAR
#include <wchar.h>
#endif
namespace boost
{
namespace range_detail
{
template <typename T>
inline void boost_range_silence_warning( const T& ) { }
/////////////////////////////////////////////////////////////////////
// end() help
/////////////////////////////////////////////////////////////////////
inline const char* str_end( const char* s, const char* )
{
return s + strlen( s );
}
#ifndef BOOST_NO_CWCHAR
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
return s + wcslen( s );
}
#else
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
if( s == 0 || s[0] == 0 )
return s;
while( *++s != 0 )
;
return s;
}
#endif
template< class Char >
inline Char* str_end( Char* s )
{
return const_cast<Char*>( str_end( s, s ) );
}
template< class T, std::size_t sz >
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost_range_array + sz;
}
template< class T, std::size_t sz >
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
return boost_range_array + sz;
}
/////////////////////////////////////////////////////////////////////
// size() help
/////////////////////////////////////////////////////////////////////
template< class Char >
inline std::size_t str_size( const Char* const& s )
{
return str_end( s ) - s;
}
template< class T, std::size_t sz >
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
{
boost_range_silence_warning( boost_range_array );
return sz;
}
template< class T, std::size_t sz >
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
{
boost_range_silence_warning( boost_range_array );
return sz;
}
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View File

@@ -0,0 +1,78 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_ITERATOR_HPP
#define BOOST_RANGE_DETAIL_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <boost/static_assert.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_iterator_ {
template< typename C >
struct pts
{
typedef int type;
};
};
template<>
struct range_iterator_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type;
};
};
template<>
struct range_iterator_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_iterator_<array_>
{
template< typename T >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME
remove_extent<T>::type* type;
};
};
}
template< typename C >
class range_mutable_iterator
{
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef typename range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@@ -0,0 +1,344 @@
// 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.
//
// 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/utility.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
{
return selected ? *m_it2 : *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_const<
typename iterator_reference<Iterator2>::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,931 @@
#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
#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,180 @@
// 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>
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 found,
SinglePassRange& rng)
{
return type(boost::begin(rng), boost::end(rng));
}
};
}
#endif // include guard

View File

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

View File

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

View File

@@ -0,0 +1,77 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_SFINAE_HPP
#define BOOST_RANGE_DETAIL_SFINAE_HPP
#include <boost/range/config.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <utility>
namespace boost
{
namespace range_detail
{
using type_traits::yes_type;
using type_traits::no_type;
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
yes_type is_string_impl( const char* const );
yes_type is_string_impl( const wchar_t* const );
no_type is_string_impl( ... );
template< std::size_t sz >
yes_type is_char_array_impl( char BOOST_RANGE_ARRAY_REF()[sz] );
template< std::size_t sz >
yes_type is_char_array_impl( const char BOOST_RANGE_ARRAY_REF()[sz] );
no_type is_char_array_impl( ... );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( const wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
no_type is_wchar_t_array_impl( ... );
yes_type is_char_ptr_impl( char* const );
no_type is_char_ptr_impl( ... );
yes_type is_const_char_ptr_impl( const char* const );
no_type is_const_char_ptr_impl( ... );
yes_type is_wchar_t_ptr_impl( wchar_t* const );
no_type is_wchar_t_ptr_impl( ... );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* const );
no_type is_const_wchar_t_ptr_impl( ... );
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
yes_type is_pair_impl( const std::pair<Iterator,Iterator>* );
no_type is_pair_impl( ... );
//////////////////////////////////////////////////////////////////////
// tags
//////////////////////////////////////////////////////////////////////
struct char_or_wchar_t_array_tag {};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View File

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

View File

@@ -0,0 +1,70 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_SIZE_TYPE_HPP
#define BOOST_RANGE_DETAIL_SIZE_TYPE_HPP
#include <boost/range/detail/common.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_size_type_;
template<>
struct range_size_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::size_type type;
};
};
template<>
struct range_size_type_<std_pair_>
{
template< typename P >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<array_>
{
template< typename A >
struct pts
{
typedef std::size_t type;
};
};
}
template< typename C >
class range_size
{
typedef typename range_detail::range<C>::type c_type;
public:
typedef typename range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@@ -0,0 +1,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) && (_MSC_VER >= 1020)
# 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

View File

@@ -0,0 +1,72 @@
// Boost.Range library
//
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
#define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
#include <boost/range/detail/common.hpp>
#include <boost/range/detail/remove_extent.hpp>
#include <boost/iterator/iterator_traits.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_value_type_;
template<>
struct range_value_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME C::value_type type;
};
};
template<>
struct range_value_type_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
};
};
template<>
struct range_value_type_<array_>
{
template< typename T >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
};
};
}
template< typename C >
class range_value
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_value_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

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

View File

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