mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
update to boost 1.39: delete unused folders
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31098 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
25dcf36ecb
commit
ef4156b24a
@ -1,103 +0,0 @@
|
||||
#ifndef BOOST_ALGORITHM_RG071801_HPP
|
||||
#define BOOST_ALGORITHM_RG071801_HPP
|
||||
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1994
|
||||
// Hewlett-Packard Company
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. Hewlett-Packard Company makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1996-1998
|
||||
// Silicon Graphics Computer Systems, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. Silicon Graphics makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
|
||||
#include "boost/iterator.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
#if 1
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
OutputIter copy_n(InputIter first, Size count,
|
||||
OutputIter result) {
|
||||
for ( ; count > 0; --count) {
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#else // !1
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
OutputIter copy_n__(InputIter first, Size count,
|
||||
OutputIter result,
|
||||
std::input_iterator_tag) {
|
||||
for ( ; count > 0; --count) {
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class RAIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n__(RAIter first, Size count,
|
||||
OutputIter result,
|
||||
std::random_access_iterator_tag) {
|
||||
RAIter last = first + count;
|
||||
return std::copy(first, last, result);
|
||||
}
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n__(InputIter first, Size count, OutputIter result) {
|
||||
typedef typename std::iterator_traits<InputIter>::iterator_category cat;
|
||||
return copy_n__(first, count, result, cat());
|
||||
}
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n(InputIter first, Size count, OutputIter result) {
|
||||
return copy_n__(first, count, result);
|
||||
}
|
||||
|
||||
#endif // 1
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ALGORITHM_RG071801_HPP
|
@ -1,482 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BASE_RG071801_HPP
|
||||
#define BASE_RG071801_HPP
|
||||
|
||||
//
|
||||
// base.hpp - some implementation base classes for from which
|
||||
// functionality is acquired
|
||||
//
|
||||
|
||||
#include "boost/multi_array/extent_range.hpp"
|
||||
#include "boost/multi_array/extent_gen.hpp"
|
||||
#include "boost/multi_array/index_range.hpp"
|
||||
#include "boost/multi_array/index_gen.hpp"
|
||||
#include "boost/multi_array/storage_order.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp" //for ignore_unused_...
|
||||
#include "boost/mpl/eval_if.hpp"
|
||||
#include "boost/mpl/if.hpp"
|
||||
#include "boost/mpl/size_t.hpp"
|
||||
#include "boost/mpl/aux_/msvc_eti_base.hpp"
|
||||
#include "boost/iterator/reverse_iterator.hpp"
|
||||
#include "boost/static_assert.hpp"
|
||||
#include "boost/type.hpp"
|
||||
#include "boost/assert.hpp"
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class declarations
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T, std::size_t NumDims,
|
||||
typename Allocator = std::allocator<T> >
|
||||
class multi_array;
|
||||
|
||||
// This is a public interface for use by end users!
|
||||
namespace multi_array_types {
|
||||
typedef boost::detail::multi_array::size_type size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef boost::detail::multi_array::index index;
|
||||
typedef detail::multi_array::index_range<index,size_type> index_range;
|
||||
typedef detail::multi_array::extent_range<index,size_type> extent_range;
|
||||
typedef detail::multi_array::index_gen<0,0> index_gen;
|
||||
typedef detail::multi_array::extent_gen<0> extent_gen;
|
||||
}
|
||||
|
||||
|
||||
// boost::extents and boost::indices are now a part of the public
|
||||
// interface. That way users don't necessarily have to create their
|
||||
// own objects. On the other hand, one may not want the overhead of
|
||||
// object creation in small-memory environments. Thus, the objects
|
||||
// can be left undefined by defining BOOST_MULTI_ARRAY_NO_GENERATORS
|
||||
// before loading multi_array.hpp.
|
||||
#if !BOOST_MULTI_ARRAY_NO_GENERATORS
|
||||
namespace {
|
||||
multi_array_types::extent_gen extents;
|
||||
multi_array_types::index_gen indices;
|
||||
}
|
||||
#endif // BOOST_MULTI_ARRAY_NO_GENERATORS
|
||||
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
class sub_array;
|
||||
|
||||
template <typename T, std::size_t NumDims, typename TPtr = const T*>
|
||||
class const_sub_array;
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference>
|
||||
class array_iterator;
|
||||
|
||||
template <typename T, std::size_t NumDims, typename TPtr = const T*>
|
||||
class const_multi_array_view;
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
class multi_array_view;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class interfaces
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class multi_array_base {
|
||||
public:
|
||||
typedef multi_array_types::size_type size_type;
|
||||
typedef multi_array_types::difference_type difference_type;
|
||||
typedef multi_array_types::index index;
|
||||
typedef multi_array_types::index_range index_range;
|
||||
typedef multi_array_types::extent_range extent_range;
|
||||
typedef multi_array_types::index_gen index_gen;
|
||||
typedef multi_array_types::extent_gen extent_gen;
|
||||
};
|
||||
|
||||
//
|
||||
// value_accessor_n
|
||||
// contains the routines for accessing elements from
|
||||
// N-dimensional views.
|
||||
//
|
||||
template<typename T, std::size_t NumDims>
|
||||
class value_accessor_n : public multi_array_base {
|
||||
typedef multi_array_base super_type;
|
||||
public:
|
||||
typedef typename super_type::index index;
|
||||
|
||||
//
|
||||
// public typedefs used by classes that inherit from this base
|
||||
//
|
||||
typedef T element;
|
||||
typedef boost::multi_array<T,NumDims-1> value_type;
|
||||
typedef sub_array<T,NumDims-1> reference;
|
||||
typedef const_sub_array<T,NumDims-1> const_reference;
|
||||
|
||||
protected:
|
||||
// used by array operator[] and iterators to get reference types.
|
||||
template <typename Reference, typename TPtr>
|
||||
Reference access(boost::type<Reference>,index idx,TPtr base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_bases) const {
|
||||
|
||||
BOOST_ASSERT(idx - index_bases[0] >= 0);
|
||||
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
|
||||
// return a sub_array<T,NDims-1> proxy object
|
||||
TPtr newbase = base + idx * strides[0];
|
||||
return Reference(newbase,extents+1,strides+1,index_bases+1);
|
||||
|
||||
}
|
||||
|
||||
value_accessor_n() { }
|
||||
~value_accessor_n() { }
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// value_accessor_one
|
||||
// contains the routines for accessing reference elements from
|
||||
// 1-dimensional views.
|
||||
//
|
||||
template<typename T>
|
||||
class value_accessor_one : public multi_array_base {
|
||||
typedef multi_array_base super_type;
|
||||
public:
|
||||
typedef typename super_type::index index;
|
||||
//
|
||||
// public typedefs for use by classes that inherit it.
|
||||
//
|
||||
typedef T element;
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef T const& const_reference;
|
||||
|
||||
protected:
|
||||
// used by array operator[] and iterators to get reference types.
|
||||
template <typename Reference, typename TPtr>
|
||||
Reference access(boost::type<Reference>,index idx,TPtr base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_bases) const {
|
||||
|
||||
ignore_unused_variable_warning(index_bases);
|
||||
ignore_unused_variable_warning(extents);
|
||||
BOOST_ASSERT(idx - index_bases[0] >= 0);
|
||||
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
|
||||
return *(base + idx * strides[0]);
|
||||
}
|
||||
|
||||
value_accessor_one() { }
|
||||
~value_accessor_one() { }
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// choose value accessor begins
|
||||
//
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
struct choose_value_accessor_n {
|
||||
typedef value_accessor_n<T,NumDims> type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct choose_value_accessor_one {
|
||||
typedef value_accessor_one<T> type;
|
||||
};
|
||||
|
||||
template <typename T, typename NumDims>
|
||||
struct value_accessor_generator {
|
||||
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims::value);
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if_c<(dimensionality == 1),
|
||||
choose_value_accessor_one<T>,
|
||||
choose_value_accessor_n<T,dimensionality>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
struct eti_value_accessor
|
||||
{
|
||||
typedef int index;
|
||||
typedef int size_type;
|
||||
typedef int element;
|
||||
typedef int index_range;
|
||||
typedef int value_type;
|
||||
typedef int reference;
|
||||
typedef int const_reference;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct value_accessor_generator<int,int>
|
||||
{
|
||||
typedef eti_value_accessor type;
|
||||
};
|
||||
|
||||
template <class T, class NumDims>
|
||||
struct associated_types
|
||||
: mpl::aux::msvc_eti_base<
|
||||
typename value_accessor_generator<T,NumDims>::type
|
||||
>::type
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct associated_types<int,int> : eti_value_accessor {};
|
||||
|
||||
#else
|
||||
|
||||
template <class T, class NumDims>
|
||||
struct associated_types
|
||||
: value_accessor_generator<T,NumDims>::type
|
||||
{};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// choose value accessor ends
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// multi_array_base
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, std::size_t NumDims>
|
||||
class multi_array_impl_base
|
||||
:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
public mpl::aux::msvc_eti_base<
|
||||
typename value_accessor_generator<T,mpl::size_t<NumDims> >::type
|
||||
>::type
|
||||
#else
|
||||
public value_accessor_generator<T,mpl::size_t<NumDims> >::type
|
||||
#endif
|
||||
{
|
||||
typedef associated_types<T,mpl::size_t<NumDims> > types;
|
||||
public:
|
||||
typedef typename types::index index;
|
||||
typedef typename types::size_type size_type;
|
||||
typedef typename types::element element;
|
||||
typedef typename types::index_range index_range;
|
||||
typedef typename types::value_type value_type;
|
||||
typedef typename types::reference reference;
|
||||
typedef typename types::const_reference const_reference;
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct subarray {
|
||||
typedef boost::detail::multi_array::sub_array<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct const_subarray {
|
||||
typedef boost::detail::multi_array::const_sub_array<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
//
|
||||
// iterator support
|
||||
//
|
||||
typedef array_iterator<T,T*,mpl::size_t<NumDims>,reference> iterator;
|
||||
typedef array_iterator<T,T const*,mpl::size_t<NumDims>,const_reference> const_iterator;
|
||||
|
||||
typedef ::boost::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef ::boost::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims);
|
||||
protected:
|
||||
|
||||
multi_array_impl_base() { }
|
||||
~multi_array_impl_base() { }
|
||||
|
||||
// Used by operator() in our array classes
|
||||
template <typename Reference, typename IndexList, typename TPtr>
|
||||
Reference access_element(boost::type<Reference>,
|
||||
const IndexList& indices,
|
||||
TPtr base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_bases) const {
|
||||
|
||||
ignore_unused_variable_warning(index_bases);
|
||||
ignore_unused_variable_warning(extents);
|
||||
#if !defined(NDEBUG) && !defined(BOOST_DISABLE_ASSERTS)
|
||||
for (size_type i = 0; i != NumDims; ++i) {
|
||||
BOOST_ASSERT(indices[i] - index_bases[i] >= 0);
|
||||
BOOST_ASSERT(size_type(indices[i] - index_bases[i]) < extents[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
index offset = 0;
|
||||
for (size_type n = 0; n != NumDims; ++n)
|
||||
offset += indices[n] * strides[n];
|
||||
|
||||
return base[offset];
|
||||
}
|
||||
|
||||
template <typename StrideList, typename ExtentList>
|
||||
void compute_strides(StrideList& stride_list, ExtentList& extent_list,
|
||||
const general_storage_order<NumDims>& storage)
|
||||
{
|
||||
// invariant: stride = the stride for dimension n
|
||||
index stride = 1;
|
||||
for (size_type n = 0; n != NumDims; ++n) {
|
||||
index stride_sign = +1;
|
||||
|
||||
if (!storage.ascending(storage.ordering(n)))
|
||||
stride_sign = -1;
|
||||
|
||||
// The stride for this dimension is the product of the
|
||||
// lengths of the ranks minor to it.
|
||||
stride_list[storage.ordering(n)] = stride * stride_sign;
|
||||
|
||||
stride *= extent_list[storage.ordering(n)];
|
||||
}
|
||||
}
|
||||
|
||||
// This calculates the offset to the array base pointer due to:
|
||||
// 1. dimensions stored in descending order
|
||||
// 2. non-zero dimension index bases
|
||||
template <typename StrideList, typename ExtentList, typename BaseList>
|
||||
index
|
||||
calculate_origin_offset(const StrideList& stride_list,
|
||||
const ExtentList& extent_list,
|
||||
const general_storage_order<NumDims>& storage,
|
||||
const BaseList& index_base_list)
|
||||
{
|
||||
return
|
||||
calculate_descending_dimension_offset(stride_list,extent_list,
|
||||
storage) +
|
||||
calculate_indexing_offset(stride_list,index_base_list);
|
||||
}
|
||||
|
||||
// This calculates the offset added to the base pointer that are
|
||||
// caused by descending dimensions
|
||||
template <typename StrideList, typename ExtentList>
|
||||
index
|
||||
calculate_descending_dimension_offset(const StrideList& stride_list,
|
||||
const ExtentList& extent_list,
|
||||
const general_storage_order<NumDims>& storage)
|
||||
{
|
||||
index offset = 0;
|
||||
if (!storage.all_dims_ascending())
|
||||
for (size_type n = 0; n != NumDims; ++n)
|
||||
if (!storage.ascending(n))
|
||||
offset -= (extent_list[n] - 1) * stride_list[n];
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
// This is used to reindex array_views, which are no longer
|
||||
// concerned about storage order (specifically, whether dimensions
|
||||
// are ascending or descending) since the viewed array handled it.
|
||||
|
||||
template <typename StrideList, typename BaseList>
|
||||
index
|
||||
calculate_indexing_offset(const StrideList& stride_list,
|
||||
const BaseList& index_base_list)
|
||||
{
|
||||
index offset = 0;
|
||||
for (size_type n = 0; n != NumDims; ++n)
|
||||
offset -= stride_list[n] * index_base_list[n];
|
||||
return offset;
|
||||
}
|
||||
|
||||
// Slicing using an index_gen.
|
||||
// Note that populating an index_gen creates a type that encodes
|
||||
// both the number of dimensions in the current Array (NumDims), and
|
||||
// the Number of dimensions for the resulting view. This allows the
|
||||
// compiler to fail if the dimensions aren't completely accounted
|
||||
// for. For reasons unbeknownst to me, a BOOST_STATIC_ASSERT
|
||||
// within the member function template does not work. I should add a
|
||||
// note to the documentation specifying that you get a damn ugly
|
||||
// error message if you screw up in your slicing code.
|
||||
template <typename ArrayRef, int NDims, typename TPtr>
|
||||
ArrayRef
|
||||
generate_array_view(boost::type<ArrayRef>,
|
||||
const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_bases,
|
||||
TPtr base) const {
|
||||
|
||||
boost::array<index,NDims> new_strides;
|
||||
boost::array<index,NDims> new_extents;
|
||||
|
||||
index offset = 0;
|
||||
size_type dim = 0;
|
||||
for (size_type n = 0; n != NumDims; ++n) {
|
||||
const index default_start = index_bases[n];
|
||||
const index default_finish = default_start+extents[n];
|
||||
const index_range& current_range = indices.ranges_[n];
|
||||
index start = current_range.get_start(default_start);
|
||||
index finish = current_range.get_finish(default_finish);
|
||||
index index_factor = current_range.stride();
|
||||
|
||||
// integral trick for ceiling((finish-start) / index_factor)
|
||||
index shrinkage = index_factor > 0 ? 1 : -1;
|
||||
index len = (finish - start + (index_factor - shrinkage)) / index_factor;
|
||||
|
||||
BOOST_ASSERT(index_bases[n] <= start &&
|
||||
start <= index_bases[n]+index(extents[n]));
|
||||
BOOST_ASSERT(index_bases[n] <= finish &&
|
||||
finish <= index_bases[n]+index(extents[n]));
|
||||
BOOST_ASSERT(index_factor != 0);
|
||||
|
||||
// the array data pointer is modified to account for non-zero
|
||||
// bases during slicing (see [Garcia] for the math involved)
|
||||
offset += start * strides[n];
|
||||
|
||||
if (!current_range.is_degenerate()) {
|
||||
|
||||
// The index_factor for each dimension is included into the
|
||||
// strides for the array_view (see [Garcia] for the math involved).
|
||||
new_strides[dim] = index_factor * strides[n];
|
||||
|
||||
// calculate new extents
|
||||
new_extents[dim] = len;
|
||||
++dim;
|
||||
}
|
||||
}
|
||||
BOOST_ASSERT(dim == NDims);
|
||||
|
||||
return
|
||||
ArrayRef(base+offset,
|
||||
new_extents,
|
||||
new_strides);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BASE_RG071801_HPP
|
@ -1,62 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef COLLECTION_CONCEPT_RG103101_HPP
|
||||
#define COLLECTION_CONCEPT_RG103101_HPP
|
||||
|
||||
#include "boost/concept_check.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
//===========================================================================
|
||||
// Collection Concept
|
||||
|
||||
template <class Collection>
|
||||
struct CollectionConcept
|
||||
{
|
||||
typedef typename Collection::value_type value_type;
|
||||
typedef typename Collection::iterator iterator;
|
||||
typedef typename Collection::const_iterator const_iterator;
|
||||
typedef typename Collection::reference reference;
|
||||
typedef typename Collection::const_reference const_reference;
|
||||
// typedef typename Collection::pointer pointer;
|
||||
typedef typename Collection::difference_type difference_type;
|
||||
typedef typename Collection::size_type size_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires<boost::InputIteratorConcept<iterator> >();
|
||||
boost::function_requires<boost::InputIteratorConcept<const_iterator> >();
|
||||
boost::function_requires<boost::CopyConstructibleConcept<value_type> >();
|
||||
const_constraints(c);
|
||||
i = c.begin();
|
||||
i = c.end();
|
||||
c.swap(c);
|
||||
}
|
||||
void const_constraints(const Collection& c) {
|
||||
ci = c.begin();
|
||||
ci = c.end();
|
||||
n = c.size();
|
||||
b = c.empty();
|
||||
}
|
||||
Collection c;
|
||||
bool b;
|
||||
iterator i;
|
||||
const_iterator ci;
|
||||
size_type n;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // COLLECTION_CONCEPT_RG103101_HPP
|
@ -1,215 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
|
||||
#define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
|
||||
|
||||
//
|
||||
// concept-checks.hpp - Checks out Const MultiArray and MultiArray
|
||||
// concepts
|
||||
//
|
||||
|
||||
#include "boost/concept_check.hpp"
|
||||
#include "boost/iterator/iterator_concepts.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
//
|
||||
// idgen_helper -
|
||||
// This is a helper for generating index_gen instantiations with
|
||||
// the right type in order to test the call to
|
||||
// operator[](index_gen). Since one would normally write:
|
||||
// A[ indices[range1][range2] ]; // or
|
||||
// B[ indices[index1][index2][range1] ];
|
||||
// idgen helper allows us to generate the "indices" type by
|
||||
// creating it through recursive calls.
|
||||
template <std::size_t N>
|
||||
struct idgen_helper {
|
||||
|
||||
template <typename Array, typename IdxGen, typename Call_Type>
|
||||
static void call(Array& a, const IdxGen& idgen, Call_Type c) {
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::index index;
|
||||
idgen_helper<N-1>::call(a,idgen[c],c);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct idgen_helper<0> {
|
||||
|
||||
template <typename Array, typename IdxGen, typename Call_Type>
|
||||
static void call(Array& a, const IdxGen& idgen, Call_Type) {
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::index index;
|
||||
a[ idgen ];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct ConstMultiArrayConcept
|
||||
{
|
||||
void constraints() {
|
||||
// function_requires< CopyConstructibleConcept<Array> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
a[ id ];
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = Array::dimensionality;
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
cit = a.begin();
|
||||
cit = a.end();
|
||||
crit = a.rbegin();
|
||||
crit = a.rend();
|
||||
eltp = a.origin();
|
||||
}
|
||||
|
||||
typedef typename Array::value_type value_type;
|
||||
typedef typename Array::reference reference;
|
||||
typedef typename Array::const_reference const_reference;
|
||||
typedef typename Array::size_type size_type;
|
||||
typedef typename Array::difference_type difference_type;
|
||||
typedef typename Array::iterator iterator;
|
||||
typedef typename Array::const_iterator const_iterator;
|
||||
typedef typename Array::reverse_iterator reverse_iterator;
|
||||
typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename Array::element element;
|
||||
typedef typename Array::index index;
|
||||
typedef typename Array::index_gen index_gen;
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::extent_gen extent_gen;
|
||||
typedef typename Array::extent_range extent_range;
|
||||
|
||||
Array a;
|
||||
size_type st;
|
||||
const size_type* stp;
|
||||
index id;
|
||||
const index* idp;
|
||||
const_iterator cit;
|
||||
const_reverse_iterator crit;
|
||||
const element* eltp;
|
||||
index_gen idgen;
|
||||
index_range range;
|
||||
};
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct MutableMultiArrayConcept
|
||||
{
|
||||
void constraints() {
|
||||
// function_requires< CopyConstructibleConcept<Array> >();
|
||||
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
it = a.begin();
|
||||
it = a.end();
|
||||
rit = a.rbegin();
|
||||
rit = a.rend();
|
||||
eltp = a.origin();
|
||||
const_constraints(a);
|
||||
}
|
||||
|
||||
void const_constraints(const Array& a) {
|
||||
|
||||
// value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
cit = a.begin();
|
||||
cit = a.end();
|
||||
crit = a.rbegin();
|
||||
crit = a.rend();
|
||||
eltp = a.origin();
|
||||
}
|
||||
|
||||
typedef typename Array::value_type value_type;
|
||||
typedef typename Array::reference reference;
|
||||
typedef typename Array::const_reference const_reference;
|
||||
typedef typename Array::size_type size_type;
|
||||
typedef typename Array::difference_type difference_type;
|
||||
typedef typename Array::iterator iterator;
|
||||
typedef typename Array::const_iterator const_iterator;
|
||||
typedef typename Array::reverse_iterator reverse_iterator;
|
||||
typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename Array::element element;
|
||||
typedef typename Array::index index;
|
||||
typedef typename Array::index_gen index_gen;
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::extent_gen extent_gen;
|
||||
typedef typename Array::extent_range extent_range;
|
||||
|
||||
Array a;
|
||||
size_type st;
|
||||
const size_type* stp;
|
||||
index id;
|
||||
const index* idp;
|
||||
iterator it;
|
||||
const_iterator cit;
|
||||
reverse_iterator rit;
|
||||
const_reverse_iterator crit;
|
||||
const element* eltp;
|
||||
index_gen idgen;
|
||||
index_range range;
|
||||
};
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
|
@ -1,68 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef COPY_ARRAY_RG092101_HPP
|
||||
#define COPY_ARRAY_RG092101_HPP
|
||||
|
||||
//
|
||||
// copy_array.hpp - generic code for copying the contents of one
|
||||
// Basic_MultiArray to another. We assume that they are of the same
|
||||
// shape
|
||||
//
|
||||
#include "boost/type.hpp"
|
||||
#include "boost/assert.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Element>
|
||||
class copy_dispatch {
|
||||
public:
|
||||
template <typename SourceIterator, typename DestIterator>
|
||||
static void copy_array (SourceIterator first, SourceIterator last,
|
||||
DestIterator result) {
|
||||
while (first != last) {
|
||||
copy_array(*first++,*result++);
|
||||
}
|
||||
}
|
||||
private:
|
||||
// Array2 has to be passed by VALUE here because subarray
|
||||
// pseudo-references are temporaries created by iterator::operator*()
|
||||
template <typename Array1, typename Array2>
|
||||
static void copy_array (const Array1& source, Array2 dest) {
|
||||
copy_array(source.begin(),source.end(),dest.begin());
|
||||
}
|
||||
|
||||
static void copy_array (const Element& source, Element& dest) {
|
||||
dest = source;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename Array1, typename Array2>
|
||||
void copy_array (Array1& source, Array2& dest) {
|
||||
BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
|
||||
dest.shape()));
|
||||
// Dispatch to the proper function
|
||||
typedef typename Array1::element element_type;
|
||||
copy_dispatch<element_type>::
|
||||
copy_array(source.begin(),source.end(),dest.begin());
|
||||
}
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // COPY_ARRAY_RG092101_HPP
|
@ -1,75 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_EXTENT_GEN_RG071801_HPP
|
||||
#define BOOST_EXTENT_GEN_RG071801_HPP
|
||||
|
||||
#include "boost/multi_array/extent_range.hpp"
|
||||
#include "boost/multi_array/range_list.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
|
||||
template <std::size_t NumRanges>
|
||||
class extent_gen {
|
||||
public:
|
||||
typedef boost::detail::multi_array::index index;
|
||||
typedef boost::detail::multi_array::size_type size_type;
|
||||
typedef extent_range<index,size_type> range;
|
||||
private:
|
||||
typedef typename range_list_generator<range,NumRanges>::type range_list;
|
||||
public:
|
||||
template <std::size_t Ranges>
|
||||
struct gen_type {
|
||||
typedef extent_gen<Ranges> type;
|
||||
};
|
||||
|
||||
range_list ranges_;
|
||||
|
||||
extent_gen() { }
|
||||
|
||||
// Used by operator[] to expand extent_gens
|
||||
extent_gen(const extent_gen<NumRanges-1>& rhs,
|
||||
const range& a_range)
|
||||
{
|
||||
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
|
||||
*ranges_.rbegin() = a_range;
|
||||
}
|
||||
|
||||
extent_gen<NumRanges+1>
|
||||
operator[](const range& a_range)
|
||||
{
|
||||
return extent_gen<NumRanges+1>(*this,a_range);
|
||||
}
|
||||
|
||||
extent_gen<NumRanges+1>
|
||||
operator[](index idx)
|
||||
{
|
||||
return extent_gen<NumRanges+1>(*this,range(0,idx));
|
||||
}
|
||||
|
||||
static extent_gen<0> extents() {
|
||||
return extent_gen<0>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_EXTENT_GEN_RG071801_HPP
|
@ -1,49 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_EXTENT_RANGE_RG071801_HPP
|
||||
#define BOOST_EXTENT_RANGE_RG071801_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Extent, typename SizeType>
|
||||
class extent_range : private std::pair<Extent,Extent> {
|
||||
typedef std::pair<Extent,Extent> super_type;
|
||||
public:
|
||||
typedef Extent index;
|
||||
typedef SizeType size_type;
|
||||
|
||||
extent_range(index start, index finish) :
|
||||
super_type(start,finish) { }
|
||||
|
||||
extent_range(index finish) :
|
||||
super_type(0,finish) { }
|
||||
|
||||
extent_range() : super_type(0,0) { }
|
||||
|
||||
index start() const { return super_type::first; }
|
||||
|
||||
index finish() const { return super_type::second; }
|
||||
|
||||
size_type size() const { return super_type::second - super_type::first; }
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_EXTENT_RANGE_RG071801_HPP
|
@ -1,81 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_INDEX_GEN_RG071801_HPP
|
||||
#define BOOST_INDEX_GEN_RG071801_HPP
|
||||
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array/index_range.hpp"
|
||||
#include "boost/multi_array/range_list.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
|
||||
template <int NumRanges, int NumDims>
|
||||
struct index_gen {
|
||||
private:
|
||||
typedef ::boost::detail::multi_array::index index;
|
||||
typedef ::boost::detail::multi_array::size_type size_type;
|
||||
typedef index_range<index,size_type> range;
|
||||
public:
|
||||
template <int Dims, int Ranges>
|
||||
struct gen_type {
|
||||
typedef index_gen<Ranges,Dims> type;
|
||||
};
|
||||
|
||||
typedef typename range_list_generator<range,NumRanges>::type range_list;
|
||||
range_list ranges_;
|
||||
|
||||
index_gen() { }
|
||||
|
||||
template <int ND>
|
||||
explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
|
||||
const range& r)
|
||||
{
|
||||
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
|
||||
*ranges_.rbegin() = r;
|
||||
}
|
||||
|
||||
index_gen<NumRanges+1,NumDims+1>
|
||||
operator[](const range& r) const
|
||||
{
|
||||
index_gen<NumRanges+1,NumDims+1> tmp;
|
||||
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
|
||||
*tmp.ranges_.rbegin() = r;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
index_gen<NumRanges+1,NumDims>
|
||||
operator[](index idx) const
|
||||
{
|
||||
index_gen<NumRanges+1,NumDims> tmp;
|
||||
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
|
||||
*tmp.ranges_.rbegin() = range(idx);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static index_gen<0,0> indices() {
|
||||
return index_gen<0,0>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_INDEX_GEN_RG071801_HPP
|
@ -1,188 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_INDEX_RANGE_RG071801_HPP
|
||||
#define BOOST_INDEX_RANGE_RG071801_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
// For representing intervals, also with stride.
|
||||
// A degenerate range is a range with one element.
|
||||
|
||||
// Thanks to Doug Gregor for the really cool idea of using the
|
||||
// comparison operators to express various interval types!
|
||||
|
||||
// Internally, we represent the interval as half-open.
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Index,typename SizeType>
|
||||
class index_range {
|
||||
public:
|
||||
typedef Index index;
|
||||
typedef SizeType size_type;
|
||||
|
||||
private:
|
||||
static index from_start()
|
||||
{ return (std::numeric_limits<index>::min)(); }
|
||||
|
||||
static index to_end()
|
||||
{ return (std::numeric_limits<index>::max)(); }
|
||||
|
||||
public:
|
||||
|
||||
index_range()
|
||||
{
|
||||
start_ = from_start();
|
||||
finish_ = to_end();
|
||||
stride_ = 1;
|
||||
degenerate_ = false;
|
||||
}
|
||||
|
||||
explicit index_range(index pos)
|
||||
{
|
||||
start_ = pos;
|
||||
finish_ = pos+1;
|
||||
stride_ = 1;
|
||||
degenerate_ = true;
|
||||
}
|
||||
|
||||
explicit index_range(index start, index finish, index stride=1)
|
||||
: start_(start), finish_(finish), stride_(stride),
|
||||
degenerate_(false)
|
||||
{ }
|
||||
|
||||
|
||||
// These are for chaining assignments to an index_range
|
||||
index_range& start(index s) {
|
||||
start_ = s;
|
||||
degenerate_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
index_range& finish(index f) {
|
||||
finish_ = f;
|
||||
degenerate_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
index_range& stride(index s) { stride_ = s; return *this; }
|
||||
|
||||
index start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
index get_start(index low_index_range = index_range::from_start()) const
|
||||
{
|
||||
if (start_ == from_start())
|
||||
return low_index_range;
|
||||
return start_;
|
||||
}
|
||||
|
||||
index finish() const
|
||||
{
|
||||
return finish_;
|
||||
}
|
||||
|
||||
index get_finish(index high_index_range = index_range::to_end()) const
|
||||
{
|
||||
if (finish_ == to_end())
|
||||
return high_index_range;
|
||||
return finish_;
|
||||
}
|
||||
|
||||
index stride() const { return stride_; }
|
||||
|
||||
void set_index_range(index start, index finish, index stride=1)
|
||||
{
|
||||
start_ = start;
|
||||
finish_ = finish;
|
||||
stride_ = stride;
|
||||
}
|
||||
|
||||
static index_range all()
|
||||
{ return index_range(from_start(), to_end(), 1); }
|
||||
|
||||
bool is_degenerate() const { return degenerate_; }
|
||||
|
||||
index_range operator-(index shift) const
|
||||
{
|
||||
return index_range(start_ - shift, finish_ - shift, stride_);
|
||||
}
|
||||
|
||||
index_range operator+(index shift) const
|
||||
{
|
||||
return index_range(start_ + shift, finish_ + shift, stride_);
|
||||
}
|
||||
|
||||
index operator[](unsigned i) const
|
||||
{
|
||||
return start_ + i * stride_;
|
||||
}
|
||||
|
||||
index operator()(unsigned i) const
|
||||
{
|
||||
return start_ + i * stride_;
|
||||
}
|
||||
|
||||
// add conversion to std::slice?
|
||||
|
||||
public:
|
||||
index start_, finish_, stride_;
|
||||
bool degenerate_;
|
||||
};
|
||||
|
||||
// Express open and closed interval end-points using the comparison
|
||||
// operators.
|
||||
|
||||
// left closed
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<=(Index s, const index_range<Index,SizeType>& r)
|
||||
{
|
||||
return index_range<Index,SizeType>(s, r.finish(), r.stride());
|
||||
}
|
||||
|
||||
// left open
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<(Index s, const index_range<Index,SizeType>& r)
|
||||
{
|
||||
return index_range<Index,SizeType>(s + 1, r.finish(), r.stride());
|
||||
}
|
||||
|
||||
// right open
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<(const index_range<Index,SizeType>& r, Index f)
|
||||
{
|
||||
return index_range<Index,SizeType>(r.start(), f, r.stride());
|
||||
}
|
||||
|
||||
// right closed
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<=(const index_range<Index,SizeType>& r, Index f)
|
||||
{
|
||||
return index_range<Index,SizeType>(r.start(), f + 1, r.stride());
|
||||
}
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_INDEX_RANGE_RG071801_HPP
|
@ -1,170 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef ITERATOR_RG071801_HPP
|
||||
#define ITERATOR_RG071801_HPP
|
||||
|
||||
//
|
||||
// iterator.hpp - implementation of iterators for the
|
||||
// multi-dimensional array class
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/iterator/iterator_facade.hpp"
|
||||
#include "boost/mpl/aux_/msvc_eti_base.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// iterator components
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T>
|
||||
struct operator_arrow_proxy
|
||||
{
|
||||
operator_arrow_proxy(T const& px) : value_(px) {}
|
||||
T* operator->() const { return &value_; }
|
||||
// This function is needed for MWCW and BCC, which won't call operator->
|
||||
// again automatically per 13.3.1.2 para 8
|
||||
operator T*() const { return &value_; }
|
||||
mutable T value_;
|
||||
};
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference>
|
||||
class array_iterator;
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference>
|
||||
class array_iterator
|
||||
: public
|
||||
iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference>
|
||||
, typename associated_types<T,NumDims>::value_type
|
||||
, boost::random_access_traversal_tag
|
||||
, Reference
|
||||
>
|
||||
, private
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
mpl::aux::msvc_eti_base<typename
|
||||
#endif
|
||||
value_accessor_generator<T,NumDims>::type
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
>::type
|
||||
#endif
|
||||
{
|
||||
friend class iterator_core_access;
|
||||
typedef detail::multi_array::associated_types<T,NumDims> access_t;
|
||||
|
||||
typedef iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference>
|
||||
, typename detail::multi_array::associated_types<T,NumDims>::value_type
|
||||
, boost::random_access_traversal_tag
|
||||
, Reference
|
||||
> facade_type;
|
||||
|
||||
typedef typename access_t::index index;
|
||||
typedef typename access_t::size_type size_type;
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
template <typename, typename, typename, typename>
|
||||
friend class array_iterator;
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
|
||||
index idx_;
|
||||
TPtr base_;
|
||||
const size_type* extents_;
|
||||
const index* strides_;
|
||||
const index* index_base_;
|
||||
|
||||
public:
|
||||
// Typedefs to circumvent ambiguities between parent classes
|
||||
typedef typename facade_type::reference reference;
|
||||
typedef typename facade_type::value_type value_type;
|
||||
typedef typename facade_type::difference_type difference_type;
|
||||
|
||||
array_iterator() {}
|
||||
|
||||
array_iterator(index idx, TPtr base, const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
idx_(idx), base_(base), extents_(extents),
|
||||
strides_(strides), index_base_(index_base) { }
|
||||
|
||||
template <typename OPtr, typename ORef>
|
||||
array_iterator(
|
||||
const array_iterator<T,OPtr,NumDims,ORef>& rhs
|
||||
, typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
|
||||
)
|
||||
: idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
|
||||
strides_(rhs.strides_), index_base_(rhs.index_base_) { }
|
||||
|
||||
|
||||
// RG - we make our own operator->
|
||||
operator_arrow_proxy<reference>
|
||||
operator->() const
|
||||
{
|
||||
return operator_arrow_proxy<reference>(this->dereference());
|
||||
}
|
||||
|
||||
|
||||
reference dereference() const
|
||||
{
|
||||
typedef typename value_accessor_generator<T,NumDims>::type accessor;
|
||||
return accessor::access(boost::type<reference>(),
|
||||
idx_,
|
||||
base_,
|
||||
extents_,
|
||||
strides_,
|
||||
index_base_);
|
||||
}
|
||||
|
||||
void increment() { ++idx_; }
|
||||
void decrement() { --idx_; }
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
bool equal(IteratorAdaptor& rhs) const {
|
||||
const std::size_t N = NumDims::value;
|
||||
return (idx_ == rhs.idx_) &&
|
||||
(base_ == rhs.base_) &&
|
||||
( (extents_ == rhs.extents_) ||
|
||||
std::equal(extents_,extents_+N,rhs.extents_) ) &&
|
||||
( (strides_ == rhs.strides_) ||
|
||||
std::equal(strides_,strides_+N,rhs.strides_) ) &&
|
||||
( (index_base_ == rhs.index_base_) ||
|
||||
std::equal(index_base_,index_base_+N,rhs.index_base_) );
|
||||
}
|
||||
|
||||
template <class DifferenceType>
|
||||
void advance(DifferenceType n) {
|
||||
idx_ += n;
|
||||
}
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
typename facade_type::difference_type
|
||||
distance_to(IteratorAdaptor& rhs) const {
|
||||
return rhs.idx_ - idx_;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // ITERATOR_RG071801_HPP
|
@ -1,633 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_REF_RG071801_HPP
|
||||
#define BOOST_MULTI_ARRAY_REF_RG071801_HPP
|
||||
|
||||
//
|
||||
// multi_array_ref.hpp - code for creating "views" of array data.
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/collection_concept.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/multi_array/iterator.hpp"
|
||||
#include "boost/multi_array/storage_order.hpp"
|
||||
#include "boost/multi_array/subarray.hpp"
|
||||
#include "boost/multi_array/view.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/concept_check.hpp"
|
||||
#include "boost/functional.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename T, std::size_t NumDims,
|
||||
typename TPtr = const T*
|
||||
>
|
||||
class const_multi_array_ref :
|
||||
public detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
typedef general_storage_order<NumDims> storage_order_type;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
// make const_multi_array_ref a friend of itself
|
||||
template <typename,std::size_t,typename>
|
||||
friend class const_multi_array_ref;
|
||||
#endif
|
||||
|
||||
// This ensures that const_multi_array_ref types with different TPtr
|
||||
// types can convert to each other
|
||||
template <typename OPtr>
|
||||
const_multi_array_ref(const const_multi_array_ref<T,NumDims,OPtr>& other)
|
||||
: base_(other.base_), storage_(other.storage_),
|
||||
extent_list_(other.extent_list_),
|
||||
stride_list_(other.stride_list_),
|
||||
index_base_list_(other.index_base_list_),
|
||||
origin_offset_(other.origin_offset_),
|
||||
directional_offset_(other.directional_offset_),
|
||||
num_elements_(other.num_elements_) { }
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit const_multi_array_ref(TPtr base, const ExtentList& extents) :
|
||||
base_(base), storage_(c_storage_order()) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
|
||||
index_base_list_.assign(0);
|
||||
init_multi_array_ref(extents.begin());
|
||||
}
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit const_multi_array_ref(TPtr base, const ExtentList& extents,
|
||||
const general_storage_order<NumDims>& so) :
|
||||
base_(base), storage_(so) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
|
||||
index_base_list_.assign(0);
|
||||
init_multi_array_ref(extents.begin());
|
||||
}
|
||||
|
||||
explicit const_multi_array_ref(TPtr base,
|
||||
const detail::multi_array::
|
||||
extent_gen<NumDims>& ranges) :
|
||||
base_(base), storage_(c_storage_order()) {
|
||||
|
||||
init_from_extent_gen(ranges);
|
||||
}
|
||||
|
||||
explicit const_multi_array_ref(TPtr base,
|
||||
const detail::multi_array::
|
||||
extent_gen<NumDims>& ranges,
|
||||
const general_storage_order<NumDims>& so) :
|
||||
base_(base), storage_(so) {
|
||||
|
||||
init_from_extent_gen(ranges);
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
void assign(InputIterator begin, InputIterator end) {
|
||||
boost::function_requires<InputIteratorConcept<InputIterator> >();
|
||||
|
||||
InputIterator in_iter = begin;
|
||||
T* out_iter = base_;
|
||||
std::size_t copy_count=0;
|
||||
while (in_iter != end && copy_count < num_elements_) {
|
||||
*out_iter++ = *in_iter++;
|
||||
copy_count++;
|
||||
}
|
||||
}
|
||||
|
||||
template <class BaseList>
|
||||
#ifdef BOOST_NO_SFINAE
|
||||
void
|
||||
#else
|
||||
typename
|
||||
disable_if<typename boost::is_integral<BaseList>::type,void >::type
|
||||
#endif // BOOST_NO_SFINAE
|
||||
reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<BaseList> >();
|
||||
boost::detail::multi_array::
|
||||
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
origin_offset_ =
|
||||
this->calculate_origin_offset(stride_list_,extent_list_,
|
||||
storage_,index_base_list_);
|
||||
}
|
||||
|
||||
void reindex(index value) {
|
||||
index_base_list_.assign(value);
|
||||
origin_offset_ =
|
||||
this->calculate_origin_offset(stride_list_,extent_list_,
|
||||
storage_,index_base_list_);
|
||||
}
|
||||
|
||||
template <typename SizeList>
|
||||
void reshape(const SizeList& extents) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<SizeList> >();
|
||||
BOOST_ASSERT(num_elements_ ==
|
||||
std::accumulate(extents.begin(),extents.end(),
|
||||
size_type(1),std::multiplies<size_type>()));
|
||||
|
||||
std::copy(extents.begin(),extents.end(),extent_list_.begin());
|
||||
this->compute_strides(stride_list_,extent_list_,storage_);
|
||||
|
||||
origin_offset_ =
|
||||
this->calculate_origin_offset(stride_list_,extent_list_,
|
||||
storage_,index_base_list_);
|
||||
}
|
||||
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
|
||||
size_type size() const { return extent_list_.front(); }
|
||||
|
||||
// given reshaping functionality, this is the max possible size.
|
||||
size_type max_size() const { return num_elements(); }
|
||||
|
||||
bool empty() const { return size() == 0; }
|
||||
|
||||
const size_type* shape() const {
|
||||
return extent_list_.data();
|
||||
}
|
||||
|
||||
const index* strides() const {
|
||||
return stride_list_.data();
|
||||
}
|
||||
|
||||
const element* origin() const { return base_+origin_offset_; }
|
||||
const element* data() const { return base_; }
|
||||
|
||||
size_type num_elements() const { return num_elements_; }
|
||||
|
||||
const index* index_bases() const {
|
||||
return index_base_list_.data();
|
||||
}
|
||||
|
||||
|
||||
const storage_order_type& storage_order() const {
|
||||
return storage_;
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(IndexList indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// Only allow const element access
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const
|
||||
const_multi_array_ref<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
if(std::equal(extent_list_.begin(),
|
||||
extent_list_.end(),
|
||||
rhs.extent_list_.begin()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const
|
||||
const_multi_array_ref<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const
|
||||
const_multi_array_ref<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const
|
||||
const_multi_array_ref<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const
|
||||
const_multi_array_ref<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const
|
||||
const_multi_array_ref<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
|
||||
typedef boost::array<size_type,NumDims> size_list;
|
||||
typedef boost::array<index,NumDims> index_list;
|
||||
|
||||
// This is used by multi_array, which is a subclass of this
|
||||
void set_base_ptr(TPtr new_base) { base_ = new_base; }
|
||||
|
||||
|
||||
// This constructor supports multi_array's default constructor
|
||||
// and constructors from multi_array_ref, subarray, and array_view
|
||||
explicit
|
||||
const_multi_array_ref(TPtr base,
|
||||
const storage_order_type& so,
|
||||
const index * index_bases,
|
||||
const size_type* extents) :
|
||||
base_(base), storage_(so), origin_offset_(0), directional_offset_(0)
|
||||
{
|
||||
// If index_bases or extents is null, then initialize the corresponding
|
||||
// private data to zeroed lists.
|
||||
if(index_bases) {
|
||||
boost::detail::multi_array::
|
||||
copy_n(index_bases,NumDims,index_base_list_.begin());
|
||||
} else {
|
||||
std::fill_n(index_base_list_.begin(),NumDims,0);
|
||||
}
|
||||
if(extents) {
|
||||
init_multi_array_ref(extents);
|
||||
} else {
|
||||
boost::array<index,NumDims> extent_list;
|
||||
extent_list.assign(0);
|
||||
init_multi_array_ref(extent_list.begin());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TPtr base_;
|
||||
storage_order_type storage_;
|
||||
size_list extent_list_;
|
||||
index_list stride_list_;
|
||||
index_list index_base_list_;
|
||||
index origin_offset_;
|
||||
index directional_offset_;
|
||||
size_type num_elements_;
|
||||
|
||||
private:
|
||||
// const_multi_array_ref cannot be assigned to (no deep copies!)
|
||||
const_multi_array_ref& operator=(const const_multi_array_ref& other);
|
||||
|
||||
void init_from_extent_gen(const
|
||||
detail::multi_array::
|
||||
extent_gen<NumDims>& ranges) {
|
||||
|
||||
typedef boost::array<index,NumDims> extent_list;
|
||||
|
||||
// get the index_base values
|
||||
std::transform(ranges.ranges_.begin(),ranges.ranges_.end(),
|
||||
index_base_list_.begin(),
|
||||
boost::mem_fun_ref(&extent_range::start));
|
||||
|
||||
// calculate the extents
|
||||
extent_list extents;
|
||||
std::transform(ranges.ranges_.begin(),ranges.ranges_.end(),
|
||||
extents.begin(),
|
||||
boost::mem_fun_ref(&extent_range::size));
|
||||
|
||||
init_multi_array_ref(extents.begin());
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
// RG - move me!
|
||||
template <class InputIterator>
|
||||
void init_multi_array_ref(InputIterator extents_iter) {
|
||||
boost::function_requires<InputIteratorConcept<InputIterator> >();
|
||||
|
||||
boost::detail::multi_array::
|
||||
copy_n(extents_iter,num_dimensions(),extent_list_.begin());
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
|
||||
this->compute_strides(stride_list_,extent_list_,storage_);
|
||||
|
||||
origin_offset_ =
|
||||
this->calculate_origin_offset(stride_list_,extent_list_,
|
||||
storage_,index_base_list_);
|
||||
directional_offset_ =
|
||||
this->calculate_descending_dimension_offset(stride_list_,extent_list_,
|
||||
storage_);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
class multi_array_ref :
|
||||
public const_multi_array_ref<T,NumDims,T*>
|
||||
{
|
||||
typedef const_multi_array_ref<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
typedef typename super_type::storage_order_type storage_order_type;
|
||||
typedef typename super_type::index_list index_list;
|
||||
typedef typename super_type::size_list size_list;
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <class ExtentList>
|
||||
explicit multi_array_ref(T* base, const ExtentList& extents) :
|
||||
super_type(base,extents) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
}
|
||||
|
||||
template <class ExtentList>
|
||||
explicit multi_array_ref(T* base, const ExtentList& extents,
|
||||
const general_storage_order<NumDims>& so) :
|
||||
super_type(base,extents,so) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
}
|
||||
|
||||
|
||||
explicit multi_array_ref(T* base,
|
||||
const detail::multi_array::
|
||||
extent_gen<NumDims>& ranges) :
|
||||
super_type(base,ranges) { }
|
||||
|
||||
|
||||
explicit multi_array_ref(T* base,
|
||||
const detail::multi_array::
|
||||
extent_gen<NumDims>&
|
||||
ranges,
|
||||
const general_storage_order<NumDims>& so) :
|
||||
super_type(base,ranges,so) { }
|
||||
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
multi_array_ref& operator=(const ConstMultiArray& other) {
|
||||
function_requires<
|
||||
detail::multi_array::
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),this->begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
multi_array_ref& operator=(const multi_array_ref& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),this->begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
element* origin() { return super_type::base_+super_type::origin_offset_; }
|
||||
|
||||
element* data() { return super_type::base_; }
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
// See note attached to generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename array_view<NDims>::type
|
||||
operator[](const detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),this->shape(),
|
||||
this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
// rbegin() and rend() written naively to thwart MSVC ICE.
|
||||
reverse_iterator rbegin() {
|
||||
reverse_iterator ri(end());
|
||||
return ri;
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
reverse_iterator ri(begin());
|
||||
return ri;
|
||||
}
|
||||
|
||||
// Using declarations don't seem to work for g++
|
||||
// These are the proxies to work around this.
|
||||
|
||||
const element* origin() const { return super_type::origin(); }
|
||||
const element* data() const { return super_type::data(); }
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
// See note attached to generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
protected:
|
||||
// This is only supplied to support multi_array's default constructor
|
||||
explicit multi_array_ref(T* base,
|
||||
const storage_order_type& so,
|
||||
const index* index_bases,
|
||||
const size_type* extents) :
|
||||
super_type(base,so,index_bases,extents) { }
|
||||
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_REF_RG071801_HPP
|
@ -1,70 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef RANGE_LIST_RG072501_HPP
|
||||
#define RANGE_LIST_RG072501_HPP
|
||||
//
|
||||
// range_list.hpp - helper to build boost::arrays for *_set types
|
||||
//
|
||||
|
||||
#include "boost/array.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// choose range list begins
|
||||
//
|
||||
|
||||
struct choose_range_list_n {
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct bind {
|
||||
typedef boost::array<T,NumRanges> type;
|
||||
};
|
||||
};
|
||||
|
||||
struct choose_range_list_zero {
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct bind {
|
||||
typedef boost::array<T,1> type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <std::size_t NumRanges>
|
||||
struct range_list_gen_helper {
|
||||
typedef choose_range_list_n choice;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct range_list_gen_helper<0> {
|
||||
typedef choose_range_list_zero choice;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct range_list_generator {
|
||||
private:
|
||||
typedef typename range_list_gen_helper<NumRanges>::choice Choice;
|
||||
public:
|
||||
typedef typename Choice::template bind<T,NumRanges>::type type;
|
||||
};
|
||||
|
||||
//
|
||||
// choose range list ends
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // RANGE_LIST_RG072501_HPP
|
@ -1,125 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_STORAGE_ORDER_RG071801_HPP
|
||||
#define BOOST_STORAGE_ORDER_RG071801_HPP
|
||||
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// RG - This is to make things work with VC++. So sad, so sad.
|
||||
class c_storage_order;
|
||||
class fortran_storage_order;
|
||||
|
||||
template <std::size_t NumDims>
|
||||
class general_storage_order
|
||||
{
|
||||
public:
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
template <typename OrderingIter, typename AscendingIter>
|
||||
general_storage_order(OrderingIter ordering,
|
||||
AscendingIter ascending) {
|
||||
boost::detail::multi_array::copy_n(ordering,NumDims,ordering_.begin());
|
||||
boost::detail::multi_array::copy_n(ascending,NumDims,ascending_.begin());
|
||||
}
|
||||
|
||||
// RG - ideally these would not be necessary, but some compilers
|
||||
// don't like template conversion operators. I suspect that not
|
||||
// too many folk will feel the need to use customized
|
||||
// storage_order objects, I sacrifice that feature for compiler support.
|
||||
general_storage_order(const c_storage_order&) {
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering_[i] = NumDims - 1 - i;
|
||||
}
|
||||
ascending_.assign(true);
|
||||
}
|
||||
|
||||
general_storage_order(const fortran_storage_order&) {
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering_[i] = i;
|
||||
}
|
||||
ascending_.assign(true);
|
||||
}
|
||||
|
||||
size_type ordering(size_type dim) const { return ordering_[dim]; }
|
||||
bool ascending(size_type dim) const { return ascending_[dim]; }
|
||||
|
||||
bool all_dims_ascending() const {
|
||||
return std::accumulate(ascending_.begin(),ascending_.end(),true,
|
||||
std::logical_and<bool>());
|
||||
}
|
||||
|
||||
bool operator==(general_storage_order const& rhs) const {
|
||||
return (ordering_ == rhs.ordering_) &&
|
||||
(ascending_ == rhs.ascending_);
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::array<size_type,NumDims> ordering_;
|
||||
boost::array<bool,NumDims> ascending_;
|
||||
};
|
||||
|
||||
class c_storage_order
|
||||
{
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
public:
|
||||
// This is the idiom for creating your own custom storage orders.
|
||||
// Not supported by all compilers though!
|
||||
#ifndef __MWERKS__ // Metrowerks screams "ambiguity!"
|
||||
template <std::size_t NumDims>
|
||||
operator general_storage_order<NumDims>() const {
|
||||
boost::array<size_type,NumDims> ordering;
|
||||
boost::array<bool,NumDims> ascending;
|
||||
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering[i] = NumDims - 1 - i;
|
||||
ascending[i] = true;
|
||||
}
|
||||
return general_storage_order<NumDims>(ordering.begin(),
|
||||
ascending.begin());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class fortran_storage_order
|
||||
{
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
public:
|
||||
// This is the idiom for creating your own custom storage orders.
|
||||
// Not supported by all compilers though!
|
||||
#ifndef __MWERKS__ // Metrowerks screams "ambiguity!"
|
||||
template <std::size_t NumDims>
|
||||
operator general_storage_order<NumDims>() const {
|
||||
boost::array<size_type,NumDims> ordering;
|
||||
boost::array<bool,NumDims> ascending;
|
||||
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering[i] = i;
|
||||
ascending[i] = true;
|
||||
}
|
||||
return general_storage_order<NumDims>(ordering.begin(),
|
||||
ascending.begin());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARRAY_STORAGE_RG071801_HPP
|
@ -1,399 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef SUBARRAY_RG071801_HPP
|
||||
#define SUBARRAY_RG071801_HPP
|
||||
|
||||
//
|
||||
// subarray.hpp - used to implement standard operator[] on
|
||||
// multi_arrays
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/type.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
//
|
||||
// const_sub_array
|
||||
// multi_array's proxy class to allow multiple overloads of
|
||||
// operator[] in order to provide a clean multi-dimensional array
|
||||
// interface.
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
class const_sub_array :
|
||||
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Allow default copy constructor as well.
|
||||
|
||||
template <typename OPtr>
|
||||
const_sub_array (const const_sub_array<T,NumDims,OPtr>& rhs) :
|
||||
base_(rhs.base_), extents_(rhs.extents_), strides_(rhs.strides_),
|
||||
index_base_(rhs.index_base_) {
|
||||
}
|
||||
|
||||
// const_sub_array always returns const types, regardless of its own
|
||||
// constness.
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,base_,shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
base_);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
if(std::equal(shape(),shape()+num_dimensions(),rhs.shape()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
TPtr origin() const { return base_; }
|
||||
size_type size() const { return extents_[0]; }
|
||||
size_type max_size() const { return num_elements(); }
|
||||
bool empty() const { return size() == 0; }
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
const size_type* shape() const { return extents_; }
|
||||
const index* strides() const { return strides_; }
|
||||
const index* index_bases() const { return index_base_; }
|
||||
|
||||
size_type num_elements() const {
|
||||
return std::accumulate(shape(),shape() + num_dimensions(),
|
||||
size_type(1), std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
template <typename,std::size_t> friend class value_accessor_n;
|
||||
template <typename,std::size_t,typename> friend class const_sub_array;
|
||||
#else
|
||||
public: // Should be protected
|
||||
#endif
|
||||
|
||||
const_sub_array (TPtr base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
base_(base), extents_(extents), strides_(strides),
|
||||
index_base_(index_base) {
|
||||
}
|
||||
|
||||
TPtr base_;
|
||||
const size_type* extents_;
|
||||
const index* strides_;
|
||||
const index* index_base_;
|
||||
private:
|
||||
// const_sub_array cannot be assigned to (no deep copies!)
|
||||
const_sub_array& operator=(const const_sub_array&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// sub_array
|
||||
// multi_array's proxy class to allow multiple overloads of
|
||||
// operator[] in order to provide a clean multi-dimensional array
|
||||
// interface.
|
||||
template <typename T, std::size_t NumDims>
|
||||
class sub_array : public const_sub_array<T,NumDims,T*>
|
||||
{
|
||||
typedef const_sub_array<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
sub_array& operator=(const ConstMultiArray& other) {
|
||||
function_requires< boost::detail::multi_array::ConstMultiArrayConcept<
|
||||
ConstMultiArray, NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
sub_array& operator=(const sub_array& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T* origin() { return this->base_; }
|
||||
const T* origin() const { return this->base_; }
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,this->base_,this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
|
||||
reverse_iterator rbegin() {
|
||||
reverse_iterator ri(end());
|
||||
return ri;
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
reverse_iterator ri(begin());
|
||||
return ri;
|
||||
}
|
||||
|
||||
//
|
||||
// proxies
|
||||
//
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::operator[](idx);
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
template <typename,std::size_t> friend class value_accessor_n;
|
||||
#else
|
||||
public: // should be private
|
||||
#endif
|
||||
|
||||
sub_array (T* base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
super_type(base,extents,strides,index_base) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
//
|
||||
// traits classes to get sub_array types
|
||||
//
|
||||
template <typename Array, int N>
|
||||
class subarray_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::sub_array<element,N> type;
|
||||
};
|
||||
|
||||
template <typename Array, int N>
|
||||
class const_subarray_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_sub_array<element,N> type;
|
||||
};
|
||||
} // namespace boost
|
||||
|
||||
#endif // SUBARRAY_RG071801_HPP
|
@ -1,38 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
|
||||
#define BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
|
||||
|
||||
//
|
||||
// types.hpp - supply types that are needed by several headers
|
||||
//
|
||||
#include "boost/config.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array{
|
||||
|
||||
// needed typedefs
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t index;
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
|
@ -1,472 +0,0 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// 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)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
|
||||
#define BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
|
||||
|
||||
//
|
||||
// view.hpp - code for creating "views" of array data.
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/multi_array/iterator.hpp"
|
||||
#include "boost/multi_array/storage_order.hpp"
|
||||
#include "boost/multi_array/subarray.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
// TPtr = const T* defaulted in base.hpp
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
class const_multi_array_view :
|
||||
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <typename OPtr>
|
||||
const_multi_array_view(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& other) :
|
||||
base_(other.base_), origin_offset_(other.origin_offset_),
|
||||
num_elements_(other.num_elements_), extent_list_(other.extent_list_),
|
||||
stride_list_(other.stride_list_), index_base_list_(other.index_base_list_)
|
||||
{ }
|
||||
|
||||
|
||||
template <class BaseList>
|
||||
#ifdef BOOST_NO_SFINAE
|
||||
void
|
||||
#else
|
||||
typename
|
||||
disable_if<typename boost::is_integral<BaseList>::type,void >::type
|
||||
#endif
|
||||
reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<BaseList> >();
|
||||
boost::detail::multi_array::
|
||||
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
origin_offset_ =
|
||||
this->calculate_indexing_offset(stride_list_,index_base_list_);
|
||||
}
|
||||
|
||||
void reindex(index value) {
|
||||
index_base_list_.assign(value);
|
||||
origin_offset_ =
|
||||
this->calculate_indexing_offset(stride_list_,index_base_list_);
|
||||
}
|
||||
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
|
||||
size_type size() const { return extent_list_.front(); }
|
||||
size_type max_size() const { return num_elements(); }
|
||||
bool empty() const { return size() == 0; }
|
||||
|
||||
const size_type* shape() const {
|
||||
return extent_list_.data();
|
||||
}
|
||||
|
||||
const index* strides() const {
|
||||
return stride_list_.data();
|
||||
}
|
||||
|
||||
const T* origin() const { return base_+origin_offset_; }
|
||||
|
||||
size_type num_elements() const { return num_elements_; }
|
||||
|
||||
const index* index_bases() const {
|
||||
return index_base_list_.data();
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(IndexList indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// Only allow const element access
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,origin(),
|
||||
shape(),strides(),
|
||||
index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
origin());
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
if(std::equal(extent_list_.begin(),
|
||||
extent_list_.end(),
|
||||
rhs.extent_list_.begin()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
template <typename,std::size_t> friend class multi_array_impl_base;
|
||||
template <typename,std::size_t,typename> friend class const_multi_array_view;
|
||||
#else
|
||||
public: // should be protected
|
||||
#endif
|
||||
|
||||
// This constructor is used by multi_array_impl_base::generate_array_view
|
||||
// to create strides
|
||||
template <typename ExtentList, typename Index>
|
||||
explicit const_multi_array_view(TPtr base,
|
||||
const ExtentList& extents,
|
||||
const boost::array<Index,NumDims>& strides):
|
||||
base_(base), origin_offset_(0) {
|
||||
|
||||
index_base_list_.assign(0);
|
||||
|
||||
// Get the extents and strides
|
||||
boost::detail::multi_array::
|
||||
copy_n(extents.begin(),NumDims,extent_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(strides.begin(),NumDims,stride_list_.begin());
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
typedef boost::array<size_type,NumDims> size_list;
|
||||
typedef boost::array<index,NumDims> index_list;
|
||||
|
||||
TPtr base_;
|
||||
index origin_offset_;
|
||||
size_type num_elements_;
|
||||
size_list extent_list_;
|
||||
index_list stride_list_;
|
||||
index_list index_base_list_;
|
||||
|
||||
private:
|
||||
// const_multi_array_view cannot be assigned to (no deep copies!)
|
||||
const_multi_array_view& operator=(const const_multi_array_view& other);
|
||||
};
|
||||
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
class multi_array_view :
|
||||
public const_multi_array_view<T,NumDims,T*>
|
||||
{
|
||||
typedef const_multi_array_view<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
multi_array_view& operator=(const ConstMultiArray& other) {
|
||||
function_requires<
|
||||
boost::detail::multi_array::
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
multi_array_view& operator=(const multi_array_view& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
element* origin() { return this->base_+this->origin_offset_; }
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
reverse_iterator rbegin() {
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
// Using declarations don't seem to work for g++
|
||||
// These are the proxies to work around this.
|
||||
|
||||
const element* origin() const { return super_type::origin(); }
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::operator[](idx);
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
|
||||
template <int NDims>
|
||||
#else
|
||||
template <int NumDims, int NDims> // else ICE
|
||||
#endif // BOOST_MSVC
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
template <typename,std::size_t> friend class multi_array_impl_base;
|
||||
#else
|
||||
public: // should be private
|
||||
#endif
|
||||
|
||||
// constructor used by multi_array_impl_base::generate_array_view to
|
||||
// generate array views
|
||||
template <typename ExtentList, typename Index>
|
||||
explicit multi_array_view(T* base,
|
||||
const ExtentList& extents,
|
||||
const boost::array<Index,NumDims>& strides) :
|
||||
super_type(base,extents,strides) { }
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// traits classes to get array_view types
|
||||
//
|
||||
template <typename Array, int N>
|
||||
class array_view_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::multi_array_view<element,N> type;
|
||||
};
|
||||
|
||||
template <typename Array, int N>
|
||||
class const_array_view_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_multi_array_view<element,N> type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
|
||||
|
@ -1,43 +0,0 @@
|
||||
// (C) Copyright Jeremy Siek 2000.
|
||||
// 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 header replaces the implementation of ct_if that preceded the
|
||||
// introduction of Boost.MPL with a facade that defers to that reviewed and
|
||||
// accepted library.
|
||||
|
||||
// Author: Ronald Garcia
|
||||
// Date: 20 October, 2006
|
||||
|
||||
|
||||
#ifndef BOOST_CT_IF_HPP
|
||||
#define BOOST_CT_IF_HPP
|
||||
|
||||
|
||||
// A stub implementation in terms of Boost.MPL
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
// true_type and false_type are used by applications of ct_if
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <class A, class B>
|
||||
struct ct_and : boost::mpl::and_<A,B> {};
|
||||
|
||||
template <class A>
|
||||
struct ct_not : mpl::not_<A> {};
|
||||
|
||||
template <bool cond, class A, class B>
|
||||
struct ct_if : mpl::if_c<cond,A,B> {};
|
||||
|
||||
template <class cond, class A, class B>
|
||||
struct ct_if_t : mpl::if_<cond,A,B> {};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CT_IF_HPP
|
||||
|
@ -1,132 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_BEGIN_HPP
|
||||
#define BOOST_RANGE_BEGIN_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#include <boost/range/detail/begin.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
namespace range_detail
|
||||
{
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// primary template
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
range_begin( C& c )
|
||||
{
|
||||
//
|
||||
// If you get a compile-error here, it is most likely because
|
||||
// you have not implemented range_begin() properly in
|
||||
// the namespace of C
|
||||
//
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator range_begin( std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// May this be discarded? Or is it needed for bad compilers?
|
||||
//
|
||||
template< typename T, std::size_t sz >
|
||||
inline const T* range_begin( const T (&a)[sz] )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline T* range_begin( T (&a)[sz] )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
} // namespace 'range_detail'
|
||||
#endif
|
||||
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_begin( r );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_begin( r );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
|
||||
const_begin( const T& r )
|
||||
{
|
||||
return boost::begin( r );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,54 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_CONFIG_HPP
|
||||
#define BOOST_RANGE_CONFIG_HPP
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
#error "macro already defined!"
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# define BOOST_RANGE_DEDUCED_TYPENAME typename
|
||||
#else
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) && !defined(_MSC_EXTENSIONS)
|
||||
# define BOOST_RANGE_DEDUCED_TYPENAME typename
|
||||
# else
|
||||
# define BOOST_RANGE_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
|
||||
#error "macro already defined!"
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
|
||||
#define BOOST_RANGE_NO_ARRAY_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
|
||||
#define BOOST_RANGE_ARRAY_REF() (boost_range_array)
|
||||
#define BOOST_RANGE_NO_STATIC_ASSERT
|
||||
#else
|
||||
#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,64 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_CONST_ITERATOR_HPP
|
||||
#define BOOST_RANGE_CONST_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/const_iterator.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_const_iterator
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_const_iterator< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_const_iterator< T[sz] >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP
|
||||
#define BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//
|
||||
// This interface is deprecated, use range_reverse_iterator<const T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_const_reverse_iterator : range_reverse_iterator<const C>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
@ -1,117 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_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
|
||||
|
@ -1,103 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_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
|
@ -1,77 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_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
|
@ -1,29 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DIFFERENCE_TYPE_HPP
|
||||
#define BOOST_RANGE_DIFFERENCE_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_difference : iterator_difference< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_EMPTY_HPP
|
||||
#define BOOST_RANGE_EMPTY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class T >
|
||||
inline bool empty( const T& r )
|
||||
{
|
||||
return boost::begin( r ) == boost::end( r );
|
||||
}
|
||||
|
||||
} // namepace 'boost'
|
||||
|
||||
|
||||
#endif
|
@ -1,131 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_END_HPP
|
||||
#define BOOST_RANGE_END_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#include <boost/range/detail/end.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
namespace range_detail
|
||||
{
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// primary template
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
range_end( C& c )
|
||||
{
|
||||
//
|
||||
// If you get a compile-error here, it is most likely because
|
||||
// you have not implemented range_begin() properly in
|
||||
// the namespace of C
|
||||
//
|
||||
return c.end();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator range_end( std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline const T* range_end( const T (&a)[sz] )
|
||||
{
|
||||
return range_detail::array_end<T,sz>( a );
|
||||
}
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline T* range_end( T (&a)[sz] )
|
||||
{
|
||||
return range_detail::array_end<T,sz>( a );
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
} // namespace 'range_detail'
|
||||
#endif
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_end( r );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_end( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
|
||||
const_end( const T& r )
|
||||
{
|
||||
return boost::end( r );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,27 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_FUNCTIONS_HPP
|
||||
#define BOOST_RANGE_FUNCTIONS_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/size.hpp>
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/rbegin.hpp>
|
||||
#include <boost/range/rend.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -1,72 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_ITERATOR_HPP
|
||||
#define BOOST_RANGE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/mutable_iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< typename C >
|
||||
struct range_iterator
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
@ -1,659 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen & Pavol Droba 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP
|
||||
#define BOOST_RANGE_ITERATOR_RANGE_HPP
|
||||
|
||||
#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
#endif
|
||||
|
||||
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
|
||||
#ifndef BOOST_OLD_IOSTREAMS
|
||||
# if defined(__STL_CONFIG_H) && \
|
||||
!defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
|
||||
/**/
|
||||
# define BOOST_OLD_IOSTREAMS
|
||||
# endif
|
||||
#endif // #ifndef BOOST_OLD_IOSTREAMS
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#ifndef _STLP_NO_IOSTREAMS
|
||||
# ifndef BOOST_OLD_IOSTREAMS
|
||||
# include <ostream>
|
||||
# else
|
||||
# include <ostream.h>
|
||||
# endif
|
||||
#endif // _STLP_NO_IOSTREAMS
|
||||
#include <cstddef>
|
||||
|
||||
/*! \file
|
||||
Defines the \c iterator_class and related functions.
|
||||
\c iterator_range is a simple wrapper of iterator pair idiom. It provides
|
||||
a rich subset of Container interface.
|
||||
*/
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace iterator_range_detail
|
||||
{
|
||||
//
|
||||
// The functions adl_begin and adl_end are implemented in a separate
|
||||
// class for gcc-2.9x
|
||||
//
|
||||
template<typename IteratorT>
|
||||
struct iterator_range_impl {
|
||||
template< class ForwardRange >
|
||||
static IteratorT adl_begin( ForwardRange& r )
|
||||
{
|
||||
return IteratorT( boost::begin( r ) );
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
static IteratorT adl_end( ForwardRange& r )
|
||||
{
|
||||
return IteratorT( boost::end( r ) );
|
||||
}
|
||||
};
|
||||
|
||||
template< class Left, class Right >
|
||||
inline bool equal( const Left& l, const Right& r )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_difference<Left>::type sz_type;
|
||||
|
||||
sz_type l_size = boost::distance( l ),
|
||||
r_size = boost::distance( r );
|
||||
|
||||
if( l_size != r_size )
|
||||
return false;
|
||||
|
||||
return std::equal( boost::begin(l), boost::end(l),
|
||||
boost::begin(r) );
|
||||
}
|
||||
|
||||
template< class Left, class Right >
|
||||
inline bool less_than( const Left& l, const Right& r )
|
||||
{
|
||||
return std::lexicographical_compare( boost::begin(l),
|
||||
boost::end(l),
|
||||
boost::begin(r),
|
||||
boost::end(r) );
|
||||
}
|
||||
|
||||
struct range_tag { };
|
||||
struct const_range_tag { };
|
||||
|
||||
}
|
||||
|
||||
// iterator range template class -----------------------------------------//
|
||||
|
||||
//! iterator_range class
|
||||
/*!
|
||||
An \c iterator_range delimits a range in a sequence by beginning and ending iterators.
|
||||
An iterator_range can be passed to an algorithm which requires a sequence as an input.
|
||||
For example, the \c toupper() function may be used most frequently on strings,
|
||||
but can also be used on iterator_ranges:
|
||||
|
||||
\code
|
||||
boost::tolower( find( s, "UPPERCASE STRING" ) );
|
||||
\endcode
|
||||
|
||||
Many algorithms working with sequences take a pair of iterators,
|
||||
delimiting a working range, as an arguments. The \c iterator_range class is an
|
||||
encapsulation of a range identified by a pair of iterators.
|
||||
It provides a collection interface,
|
||||
so it is possible to pass an instance to an algorithm requiring a collection as an input.
|
||||
*/
|
||||
template<typename IteratorT>
|
||||
class iterator_range
|
||||
{
|
||||
protected: // Used by sub_range
|
||||
//! implementation class
|
||||
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
|
||||
public:
|
||||
|
||||
//! this type
|
||||
typedef iterator_range<IteratorT> type;
|
||||
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
|
||||
|
||||
//! Encapsulated value type
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type value_type;
|
||||
|
||||
//! Difference type
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_difference<IteratorT>::type difference_type;
|
||||
|
||||
//! Size type
|
||||
typedef std::size_t size_type; // note: must be unsigned
|
||||
|
||||
//! This type
|
||||
typedef iterator_range<IteratorT> this_type;
|
||||
|
||||
//! Refence type
|
||||
//
|
||||
// Needed because value-type is the same for
|
||||
// const and non-const iterators
|
||||
//
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_reference<IteratorT>::type reference;
|
||||
|
||||
//! const_iterator type
|
||||
/*!
|
||||
There is no distinction between const_iterator and iterator.
|
||||
These typedefs are provides to fulfill container interface
|
||||
*/
|
||||
typedef IteratorT const_iterator;
|
||||
//! iterator type
|
||||
typedef IteratorT iterator;
|
||||
|
||||
private: // for return value of operator()()
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::mpl::if_< boost::is_abstract<value_type>,
|
||||
reference, value_type >::type abstract_value_type;
|
||||
|
||||
public:
|
||||
iterator_range() : m_Begin( iterator() ), m_End( iterator() )
|
||||
#ifndef NDEBUG
|
||||
, singular( true )
|
||||
#endif
|
||||
{ }
|
||||
|
||||
//! Constructor from a pair of iterators
|
||||
template< class Iterator >
|
||||
iterator_range( Iterator Begin, Iterator End ) :
|
||||
m_Begin(Begin), m_End(End)
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( const Range& r ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( Range& r ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( Range& r, iterator_range_detail::range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
this_type& operator=( const this_type& r )
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
|
||||
#ifndef NDEBUG
|
||||
singular = r.singular;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class Iterator >
|
||||
iterator_range& operator=( const iterator_range<Iterator>& r )
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
#ifndef NDEBUG
|
||||
singular = r.is_singular();
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator_range& operator=( ForwardRange& r )
|
||||
{
|
||||
m_Begin = impl::adl_begin( r );
|
||||
m_End = impl::adl_end( r );
|
||||
#ifndef NDEBUG
|
||||
singular = false;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator_range& operator=( const ForwardRange& r )
|
||||
{
|
||||
m_Begin = impl::adl_begin( r );
|
||||
m_End = impl::adl_end( r );
|
||||
#ifndef NDEBUG
|
||||
singular = false;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
IteratorT begin() const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_Begin;
|
||||
}
|
||||
|
||||
IteratorT end() const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_End;
|
||||
}
|
||||
|
||||
difference_type size() const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_End - m_Begin;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_Begin == m_End;
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
operator bool() const
|
||||
{
|
||||
return !empty();
|
||||
}
|
||||
#else
|
||||
typedef iterator (iterator_range::*unspecified_bool_type) () const;
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return empty() ? 0: &iterator_range::end;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool equal( const iterator_range& r ) const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_Begin == r.m_Begin && m_End == r.m_End;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
bool operator==( const iterator_range& r ) const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return iterator_range_detail::equal( *this, r );
|
||||
}
|
||||
|
||||
bool operator!=( const iterator_range& r ) const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return !operator==(r);
|
||||
}
|
||||
|
||||
bool operator<( const iterator_range& r ) const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return iterator_range_detail::less_than( *this, r );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public: // convenience
|
||||
reference front() const
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
return *m_Begin;
|
||||
}
|
||||
|
||||
reference back() const
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
IteratorT last( m_End );
|
||||
return *--last;
|
||||
}
|
||||
|
||||
reference operator[]( difference_type at ) const
|
||||
{
|
||||
BOOST_ASSERT( at >= 0 && at < size() );
|
||||
return m_Begin[at];
|
||||
}
|
||||
|
||||
//
|
||||
// When storing transform iterators, operator[]()
|
||||
// fails because it returns by reference. Therefore
|
||||
// operator()() is provided for these cases.
|
||||
//
|
||||
abstract_value_type operator()( difference_type at ) const
|
||||
{
|
||||
BOOST_ASSERT( at >= 0 && at < size() );
|
||||
return m_Begin[at];
|
||||
}
|
||||
|
||||
iterator_range& advance_begin( difference_type n )
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
std::advance( m_Begin, n );
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_range& advance_end( difference_type n )
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
std::advance( m_End, n );
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
// begin and end iterators
|
||||
IteratorT m_Begin;
|
||||
IteratorT m_End;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool singular;
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool is_singular() const
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
return singular;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
//
|
||||
// Allow subclasses an easy way to access the
|
||||
// base type
|
||||
//
|
||||
typedef iterator_range iterator_range_;
|
||||
};
|
||||
|
||||
// iterator range free-standing operators ---------------------------//
|
||||
|
||||
#ifndef _STLP_NO_IOSTREAMS
|
||||
# ifndef BOOST_OLD_IOSTREAMS
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputed
|
||||
in a sequence without separators.
|
||||
*/
|
||||
template< typename IteratorT, typename Elem, typename Traits >
|
||||
inline std::basic_ostream<Elem,Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& Os,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
std::copy( r.begin(), r.end(),
|
||||
std::ostream_iterator< BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type,
|
||||
Elem, Traits>(Os) );
|
||||
return Os;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputed
|
||||
in a sequence without separators.
|
||||
*/
|
||||
template< typename IteratorT >
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& Os,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os));
|
||||
return Os;
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif // _STLP_NO_IOSTREAMS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// comparison operators
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator==( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator!=( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#else
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator==( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator==( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator!=( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator!=( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator<( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
// iterator range utilities -----------------------------------------//
|
||||
|
||||
//! iterator_range construct helper
|
||||
/*!
|
||||
Construct an \c iterator_range from a pair of iterators
|
||||
|
||||
\param Begin A begin iterator
|
||||
\param End An end iterator
|
||||
\return iterator_range object
|
||||
*/
|
||||
template< typename IteratorT >
|
||||
inline iterator_range< IteratorT >
|
||||
make_iterator_range( IteratorT Begin, IteratorT End )
|
||||
{
|
||||
return iterator_range<IteratorT>( Begin, End );
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_iterator_range( Range& r )
|
||||
{
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
( boost::begin( r ), boost::end( r ) );
|
||||
}
|
||||
|
||||
#else
|
||||
//! iterator_range construct helper
|
||||
/*!
|
||||
Construct an \c iterator_range from a \c Range containing the begin
|
||||
and end iterators.
|
||||
*/
|
||||
template< class ForwardRange >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
make_iterator_range( ForwardRange& r )
|
||||
{
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
( r, iterator_range_detail::range_tag() );
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
|
||||
make_iterator_range( const ForwardRange& r )
|
||||
{
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
|
||||
( r, iterator_range_detail::const_range_tag() );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
namespace iterator_range_detail
|
||||
{
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_range_impl( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//
|
||||
// Not worth the effort
|
||||
//
|
||||
//if( advance_begin == 0 && advance_end == 0 )
|
||||
// return make_iterator_range( r );
|
||||
//
|
||||
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
|
||||
new_begin = boost::begin( r ),
|
||||
new_end = boost::end( r );
|
||||
std::advance( new_begin, advance_begin );
|
||||
std::advance( new_end, advance_end );
|
||||
return make_iterator_range( new_begin, new_end );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_iterator_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_iterator_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
|
||||
make_iterator_range( const Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! copy a range into a sequence
|
||||
/*!
|
||||
Construct a new sequence of the specified type from the elements
|
||||
in the given range
|
||||
|
||||
\param Range An input range
|
||||
\return New sequence
|
||||
*/
|
||||
template< typename SeqT, typename Range >
|
||||
inline SeqT copy_range( const Range& r )
|
||||
{
|
||||
return SeqT( boost::begin( r ), boost::end( r ) );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#undef BOOST_OLD_IOSTREAMS
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,65 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_RBEGIN_HPP
|
||||
#define BOOST_RANGE_RBEGIN_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rbegin( C& c )
|
||||
{
|
||||
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::end( c ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rbegin( C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
iter_type;
|
||||
return iter_type( boost::end( c ) );
|
||||
}
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
rbegin( const C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
iter_type;
|
||||
return iter_type( boost::end( c ) );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
|
||||
const_rbegin( const T& r )
|
||||
{
|
||||
return boost::rbegin( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
|
@ -1,65 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_REND_HPP
|
||||
#define BOOST_RANGE_REND_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rend( C& c )
|
||||
{
|
||||
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::begin( c ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rend( C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
iter_type;
|
||||
return iter_type( boost::begin( c ) );
|
||||
}
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
rend( const C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
iter_type;
|
||||
return iter_type( boost::begin( c ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
|
||||
const_rend( const T& r )
|
||||
{
|
||||
return boost::rend( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
|
@ -1,33 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_RESULT_ITERATOR_HPP
|
||||
#define BOOST_RANGE_RESULT_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//
|
||||
// This interface is deprecated, use range_iterator<T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_result_iterator : range_iterator<C>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_REVERSE_ITERATOR_HPP
|
||||
#define BOOST_RANGE_REVERSE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_reverse_iterator
|
||||
{
|
||||
typedef reverse_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<C>::type > type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP
|
||||
#define BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//
|
||||
// This interface is deprecated, use range_reverse_iterator<T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_reverse_result_iterator : range_reverse_iterator<C>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_SIZE_HPP
|
||||
#define BOOST_RANGE_SIZE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type size( const T& r )
|
||||
{
|
||||
BOOST_ASSERT( (boost::end( r ) - boost::begin( r )) >= 0 &&
|
||||
"reachability invariant broken!" );
|
||||
return boost::end( r ) - boost::begin( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
@ -1,78 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_SIZE_TYPE_HPP
|
||||
#define BOOST_RANGE_SIZE_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/size_type.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_size
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_size< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_size< T[sz] >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
}
|
||||
|
||||
template< class T >
|
||||
struct range_size :
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct range_size<const T > : range_size<T>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
|
||||
#endif
|
@ -1,34 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_VALUE_TYPE_HPP
|
||||
#define BOOST_RANGE_VALUE_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
//#include <boost/range/detail/value_type.hpp>
|
||||
//#else
|
||||
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_value : iterator_value< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
@ -1,27 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2004-2007.
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 41369 $
|
||||
//
|
||||
// Description : enable previosly suppressed warnings
|
||||
// ***************************************************************************
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(default: 4511) // copy constructor could not be generated
|
||||
# pragma warning(default: 4512) // assignment operator could not be generated
|
||||
# pragma warning(default: 4100) // unreferenced formal parameter
|
||||
# pragma warning(default: 4996) // <symbol> was declared deprecated
|
||||
# pragma warning(default: 4355) // 'this' : used in base member initializer list
|
||||
# pragma warning(default: 4706) // assignment within conditional expression
|
||||
# pragma warning(default: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
|
||||
# pragma warning(default: 4127) // conditional expression is constant
|
||||
# pragma warning(default: 4290) // C++ exception specification ignored except to ...
|
||||
# pragma warning(default: 4180) // qualifier applied to function type has no meaning; ignored
|
||||
# pragma warning(pop)
|
||||
#endif
|
@ -1,28 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2004-2007.
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 41369 $
|
||||
//
|
||||
// Description : suppress some warnings
|
||||
// ***************************************************************************
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4511) // copy constructor could not be generated
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated
|
||||
# pragma warning(disable: 4100) // unreferenced formal parameter
|
||||
# pragma warning(disable: 4996) // <symbol> was declared deprecated
|
||||
# pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
||||
# pragma warning(disable: 4706) // assignment within conditional expression
|
||||
# pragma warning(disable: 4251) // class 'A<T>' needs to have dll-interface to be used by clients of class 'B'
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
# pragma warning(disable: 4290) // C++ exception specification ignored except to ...
|
||||
# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
|
||||
#endif
|
||||
|
@ -1,100 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2002-2007.
|
||||
// (C) Copyright Daryle Walker 2000-2001.
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 41369 $
|
||||
//
|
||||
// Description : simulate /dev/null stream
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_NULLSTREAM_HPP_071894GER
|
||||
#define BOOST_NULLSTREAM_HPP_071894GER
|
||||
|
||||
#include <ostream> // for std::basic_ostream
|
||||
#include <streambuf> // for std::basic_streambuf
|
||||
#include <string> // for std::char_traits
|
||||
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** basic_nullbuf ************** //
|
||||
// ************************************************************************** //
|
||||
// Class for a buffer that reads nothing and writes to nothing.
|
||||
// Idea from an Usenet post by Tom <the_wid@my-deja.com> at
|
||||
// 27 Oct 2000 14:06:21 GMT on comp.lang.c++.
|
||||
|
||||
template<typename CharType, class CharTraits = ::std::char_traits<CharType> >
|
||||
class basic_nullbuf : public ::std::basic_streambuf<CharType, CharTraits> {
|
||||
typedef ::std::basic_streambuf<CharType, CharTraits> base_type;
|
||||
public:
|
||||
// Types
|
||||
typedef typename base_type::char_type char_type;
|
||||
typedef typename base_type::traits_type traits_type;
|
||||
typedef typename base_type::int_type int_type;
|
||||
typedef typename base_type::pos_type pos_type;
|
||||
typedef typename base_type::off_type off_type;
|
||||
|
||||
// Use automatic default constructor and destructor
|
||||
|
||||
protected:
|
||||
// The default implementations of the miscellaneous virtual
|
||||
// member functions are sufficient.
|
||||
|
||||
// The default implementations of the input & putback virtual
|
||||
// member functions, being nowhere but EOF, are sufficient.
|
||||
|
||||
// The output virtual member functions need to be changed to
|
||||
// accept anything without any problems, instead of being at EOF.
|
||||
virtual ::std::streamsize xsputn( char_type const* /*s*/, ::std::streamsize n ) { return n; } // "s" is unused
|
||||
virtual int_type overflow( int_type c = traits_type::eof() ) { return traits_type::not_eof( c ); }
|
||||
};
|
||||
|
||||
typedef basic_nullbuf<char> nullbuf;
|
||||
typedef basic_nullbuf<wchar_t> wnullbuf;
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** basic_onullstream ************** //
|
||||
// ************************************************************************** //
|
||||
// Output streams based on basic_nullbuf.
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
||||
#endif
|
||||
|
||||
template< typename CharType, class CharTraits = ::std::char_traits<CharType> >
|
||||
class basic_onullstream : private boost::base_from_member<basic_nullbuf<CharType, CharTraits> >
|
||||
, public ::std::basic_ostream<CharType, CharTraits> {
|
||||
typedef boost::base_from_member<basic_nullbuf<CharType, CharTraits> > pbase_type;
|
||||
typedef ::std::basic_ostream<CharType, CharTraits> base_type;
|
||||
public:
|
||||
// Constructor
|
||||
basic_onullstream() : pbase_type(), base_type( &this->pbase_type::member ) {}
|
||||
};
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(default: 4355)
|
||||
#endif
|
||||
|
||||
typedef basic_onullstream<char> onullstream;
|
||||
typedef basic_onullstream<wchar_t> wonullstream;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_NULLSTREAM_HPP_071894GER
|
Loading…
Reference in New Issue
Block a user