diff --git a/include/boost/python/suite/indexing/slice.hpp b/include/boost/python/suite/indexing/slice.hpp index 5b064194..82d5c290 100755 --- a/include/boost/python/suite/indexing/slice.hpp +++ b/include/boost/python/suite/indexing/slice.hpp @@ -39,24 +39,26 @@ namespace boost { namespace python { namespace indexing { // This class provides a convenient interface to Python slice // objects that contain integer bound and stride values. - integer_slice (slice const &, int sequenceLength); + typedef int index_type; + + integer_slice (slice const &, index_type sequenceLength); // integer_slice must know how big the container is so it can // adjust for negative indexes, etc... - int start() const { return mStart; } - int step() const { return mStep; } - int stop() const { return mStop; } + index_type start() const { return mStart; } + index_type step() const { return mStep; } + index_type stop() const { return mStop; } - int size() const { return (mStop - mStart) / mStep; } + index_type size() const { return (mStop - mStart) / mStep; } - bool in_range (int index); + bool in_range (index_type index); private: slice mSlice; - int mStart; - int mStep; - int mStop; - int mDirection; + index_type mStart; + index_type mStep; + index_type mStop; + index_type mDirection; }; } } } diff --git a/src/indexing/slice.cpp b/src/indexing/slice.cpp index 09ee0843..3835c931 100755 --- a/src/indexing/slice.cpp +++ b/src/indexing/slice.cpp @@ -31,10 +31,10 @@ boost::python::indexing::slice::slice (slice const ©) // integer_slice constructor ///////////////////////////////////////////////////////////////////////////// -boost::python::indexing::integer_slice::integer_slice (slice const &sl - , int sequenceLength) +boost::python::indexing::integer_slice +::integer_slice (slice const &sl, index_type sequenceLength) : mSlice (sl) - // Leave int members uninitialized + // Leave index members uninitialized { PySlice_GetIndices (reinterpret_cast (mSlice.ptr()) , sequenceLength @@ -58,7 +58,7 @@ boost::python::indexing::integer_slice::integer_slice (slice const &sl // Check if an index is within the range of this integer_slice ///////////////////////////////////////////////////////////////////////////// -bool boost::python::indexing::integer_slice::in_range (int index) +bool boost::python::indexing::integer_slice::in_range (index_type index) { return ((mStop - index) * mDirection) > 0; }