From 26d5ca22aa5706f2a6e395a77bea40a37a57a182 Mon Sep 17 00:00:00 2001 From: Raoul Gough Date: Tue, 14 Oct 2003 11:20:25 +0000 Subject: [PATCH] Add SliceType template argument, copy SliceType object in constructor [SVN r20375] --- .../suite/indexing/int_slice_helper.hpp | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/include/boost/python/suite/indexing/int_slice_helper.hpp b/include/boost/python/suite/indexing/int_slice_helper.hpp index a667d99b..ed81fdee 100755 --- a/include/boost/python/suite/indexing/int_slice_helper.hpp +++ b/include/boost/python/suite/indexing/int_slice_helper.hpp @@ -18,20 +18,25 @@ #ifndef int_slice_helper_rmg_20031013_included #define int_slice_helper_rmg_20031013_included -#include #include namespace boost { namespace python { namespace indexing { - template + template struct int_slice_helper { + // Works with a SliceType that provides an int-like index_type + // that is convertible to the algorithm's index_param + typedef Algorithms algorithms; + typedef SliceType slice_type; + typedef typename algorithms::container container; typedef typename algorithms::reference reference; typedef typename algorithms::value_param value_param; typedef typename algorithms::container_traits container_traits; + typedef typename slice_type::index_type index_type; - int_slice_helper (slice const &sl, container &c); + int_slice_helper (container &c, slice_type const &); bool next(); @@ -44,23 +49,23 @@ namespace boost { namespace python { namespace indexing { void insert (value_param val); private: - integer_slice mSlice; + slice_type mSlice; container *mPtr; - int mPos; + index_type mPos; }; - template - int_slice_helper::int_slice_helper (slice const &sl - , container &c) - : mSlice (sl, algorithms::size (c)) + template + int_slice_helper + ::int_slice_helper (container &c, slice_type const &sl) + : mSlice (sl) , mPtr (&c) , mPos (-1) { } - template + template bool - int_slice_helper::next() + int_slice_helper::next() { bool result = false; // Assume the worst @@ -81,15 +86,15 @@ namespace boost { namespace python { namespace indexing { return result; } - template - typename int_slice_helper::reference - int_slice_helper::current () const + template + typename int_slice_helper::reference + int_slice_helper::current () const { return algorithms::get (*mPtr, mPos); } - template - void int_slice_helper::write (value_param val) + template + void int_slice_helper::write (value_param val) { if (next()) { @@ -102,8 +107,8 @@ namespace boost { namespace python { namespace indexing { } } - template - void int_slice_helper::assign (value_param val) const + template + void int_slice_helper::assign (value_param val) const { algorithms::assign (*mPtr, mPos, val); } @@ -133,8 +138,8 @@ namespace boost { namespace python { namespace indexing { }; } - template - void int_slice_helper::insert (value_param val) + template + void int_slice_helper::insert (value_param val) { if (mSlice.step() != 1) { @@ -178,8 +183,8 @@ namespace boost { namespace python { namespace indexing { }; } - template - void int_slice_helper::erase_remaining () const + template + void int_slice_helper::erase_remaining () const { if (mSlice.step() != 1) {