diff --git a/include/boost/multi_array.hpp b/include/boost/multi_array.hpp index 13ab1d5..03a601e 100644 --- a/include/boost/multi_array.hpp +++ b/include/boost/multi_array.hpp @@ -163,7 +163,7 @@ public: allocate_space(); std::copy(rhs.begin(),rhs.end(),this->begin()); } - + // Since assignment is a deep copy, multi_array_ref // contains all the necessary code. template diff --git a/include/boost/multi_array/base.hpp b/include/boost/multi_array/base.hpp index d3081d4..905e4a5 100644 --- a/include/boost/multi_array/base.hpp +++ b/include/boost/multi_array/base.hpp @@ -78,8 +78,7 @@ class sub_array; template class const_sub_array; -template +template class array_iterator; template @@ -244,20 +243,8 @@ public: // // iterator support // - - typedef typename - mpl::if_c<(NumDims == 1), - writable_lvalue_iterator_tag, - readable_writable_iterator_tag>::type iterator_tag; - - typedef typename - mpl::if_c<(NumDims == 1), - readable_lvalue_iterator_tag, - readable_iterator_tag>::type const_iterator_tag; - - typedef array_iterator iterator; - typedef array_iterator const_iterator; + typedef array_iterator iterator; + typedef array_iterator const_iterator; typedef ::boost::reverse_iterator reverse_iterator; typedef ::boost::reverse_iterator const_reverse_iterator; diff --git a/include/boost/multi_array/concept_checks.hpp b/include/boost/multi_array/concept_checks.hpp index a866231..6586618 100644 --- a/include/boost/multi_array/concept_checks.hpp +++ b/include/boost/multi_array/concept_checks.hpp @@ -19,6 +19,7 @@ // #include "boost/concept_check.hpp" +#include "boost/iterator/iterator_concepts.hpp" namespace boost { namespace detail { @@ -99,6 +100,11 @@ namespace multi_array { typedef typename Array::extent_gen extent_gen; typedef typename Array::extent_range extent_range; + BOOST_CLASS_REQUIRE(iterator, boost_concepts, ForwardTraversalConcept); + BOOST_CLASS_REQUIRE(iterator, boost_concepts, ReadableIteratorConcept); + BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ForwardTraversalConcept); + BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ReadableIteratorConcept); + Array a; size_type st; const size_type* stp; @@ -180,6 +186,12 @@ namespace multi_array { typedef typename Array::extent_gen extent_gen; typedef typename Array::extent_range extent_range; + BOOST_CLASS_REQUIRE(iterator, boost_concepts, ForwardTraversalConcept); + BOOST_CLASS_REQUIRE(iterator, boost_concepts, ReadableIteratorConcept); + BOOST_CLASS_REQUIRE(iterator, boost_concepts, WritableIteratorConcept); + BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ForwardTraversalConcept); + BOOST_CLASS_REQUIRE(const_iterator, boost_concepts, ReadableIteratorConcept); + Array a; size_type st; const size_type* stp; diff --git a/include/boost/multi_array/iterator.hpp b/include/boost/multi_array/iterator.hpp index 92409d3..2e933cf 100644 --- a/include/boost/multi_array/iterator.hpp +++ b/include/boost/multi_array/iterator.hpp @@ -43,28 +43,25 @@ struct operator_arrow_proxy }; -template +template class array_iterator : public iterator_facade< - array_iterator, + array_iterator, typename value_accessor_generator::type::value_type, - AccessCategory, - ::boost::random_access_traversal_tag, + boost::random_access_traversal_tag, Reference >, private value_accessor_generator::type { friend class iterator_core_access; - template + template friend class array_iterator; typedef typename value_accessor_generator::type access_t; typedef iterator_facade< - array_iterator, + array_iterator, typename access_t::value_type, - AccessCategory, ::boost::random_access_traversal_tag, Reference > facade_type; @@ -93,9 +90,11 @@ public: idx_(idx), base_(base), extents_(extents), strides_(strides), index_base_(index_base) { } - template - array_iterator(const - array_iterator& rhs) + template + array_iterator( + const array_iterator& rhs + , typename boost::enable_if_convertible::type* = 0 + ) : idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_), strides_(rhs.strides_), index_base_(rhs.index_base_) { } diff --git a/include/boost/multi_array/multi_array_ref.hpp b/include/boost/multi_array/multi_array_ref.hpp index 0cec5f6..d98a5c5 100644 --- a/include/boost/multi_array/multi_array_ref.hpp +++ b/include/boost/multi_array/multi_array_ref.hpp @@ -71,6 +71,9 @@ public: // make const_multi_array_ref a friend of itself template friend class const_multi_array_ref; + +// template // needed for enable_if_convertible tests +// friend class boost::detail::is_convertible_basic_impl; #endif template @@ -322,9 +325,10 @@ public: void set_base_ptr(TPtr new_base) { base_ = new_base; } template - const_multi_array_ref(const detail::multi_array:: - const_sub_array& rhs) - : base_(rhs.origin()), + const_multi_array_ref( + const detail::multi_array::const_sub_array& rhs + ) + : base_(0), // playing it "safe"; so we learn of errors storage_(c_storage_order()), origin_offset_(0), directional_offset_(0), num_elements_(rhs.num_elements()) @@ -395,7 +399,6 @@ private: } }; - template class multi_array_ref : public const_multi_array_ref diff --git a/test/Jamfile b/test/Jamfile index 4d69914..60193de 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -9,20 +9,7 @@ subproject libs/multi_array/test ; import testing ; test-suite multi_array - : [ run constructors.cpp ../../test/build/boost_test_exec_monitor ] - [ run access.cpp ../../test/build/boost_test_exec_monitor ] - [ run compare.cpp ../../test/build/boost_test_exec_monitor ] - [ run iterators.cpp ../../test/build/boost_test_exec_monitor ] - [ run slice.cpp ../../test/build/boost_test_exec_monitor ] - [ run assign.cpp ../../test/build/boost_test_exec_monitor ] - [ run index_bases.cpp ../../test/build/boost_test_exec_monitor ] - [ run storage_order.cpp ../../test/build/boost_test_exec_monitor ] - [ run reshape.cpp ../../test/build/boost_test_exec_monitor ] - [ run range1.cpp ../../test/build/boost_test_exec_monitor ] - [ run idxgen1.cpp ../../test/build/boost_test_exec_monitor ] - [ run stl_interaction.cpp ../../test/build/boost_test_exec_monitor ] - [ run resize.cpp ../../test/build/boost_test_exec_monitor ] - [ compile concept_checks.cpp ] + : [ compile-fail fail_cbracket.cpp ] [ compile-fail fail_cdata.cpp ] [ compile-fail fail_citerator.cpp ] @@ -45,4 +32,19 @@ test-suite multi_array [ compile-fail fail_ref_cview.cpp ] [ compile-fail fail_ref_cview2.cpp ] [ compile-fail fail_ref_cview3.cpp ] + + [ run constructors.cpp ../../test/build/boost_test_exec_monitor ] + [ run access.cpp ../../test/build/boost_test_exec_monitor ] + [ run compare.cpp ../../test/build/boost_test_exec_monitor ] + [ run iterators.cpp ../../test/build/boost_test_exec_monitor ] + [ run slice.cpp ../../test/build/boost_test_exec_monitor ] + [ run assign.cpp ../../test/build/boost_test_exec_monitor ] + [ run index_bases.cpp ../../test/build/boost_test_exec_monitor ] + [ run storage_order.cpp ../../test/build/boost_test_exec_monitor ] + [ run reshape.cpp ../../test/build/boost_test_exec_monitor ] + [ run range1.cpp ../../test/build/boost_test_exec_monitor ] + [ run idxgen1.cpp ../../test/build/boost_test_exec_monitor ] + [ run stl_interaction.cpp ../../test/build/boost_test_exec_monitor ] + [ run resize.cpp ../../test/build/boost_test_exec_monitor ] + [ compile concept_checks.cpp ] ;