diff --git a/include/boost/python/suite/indexing/algo_selector.hpp b/include/boost/python/suite/indexing/algo_selector.hpp index 486539d5..c83b9d43 100755 --- a/include/boost/python/suite/indexing/algo_selector.hpp +++ b/include/boost/python/suite/indexing/algo_selector.hpp @@ -1,10 +1,8 @@ -// -*- mode:c++ -*- -// // Header file algo_selector.hpp // // Automatic selection of container algorithms (and traits) for known // container types (basically, all STL container instances, as well as -// iterator_pair instances). +// iterator_range instances). // // Copyright (c) 2003 Raoul M. Gough // @@ -31,7 +29,7 @@ #include // Definitions of further supported types -#include +#include #include #include #include @@ -152,12 +150,12 @@ namespace boost { namespace python { namespace indexing { // Iterator ranges template - class selector_impl > + class selector_impl > { - typedef iterator_pair Container; + typedef iterator_range Container; - typedef iterator_pair_traits mutable_traits; - typedef iterator_pair_traits const_traits; // ? + typedef iterator_range_traits mutable_traits; + typedef iterator_range_traits const_traits; // ? public: typedef default_algorithms mutable_algorithms; diff --git a/include/boost/python/suite/indexing/container_traits.hpp b/include/boost/python/suite/indexing/container_traits.hpp index 8cba8c33..ffe1e623 100755 --- a/include/boost/python/suite/indexing/container_traits.hpp +++ b/include/boost/python/suite/indexing/container_traits.hpp @@ -1,5 +1,3 @@ -// -*- mode:c++ -*- -// // Header file container_traits.hpp // // Traits information about entire containers for use in determining @@ -92,11 +90,11 @@ namespace boost { namespace python { namespace indexing { }; ///////////////////////////////////////////////////////////////////////// - // Traits for the iterator_pair container emulator + // Traits for the iterator_range container emulator ///////////////////////////////////////////////////////////////////////// - template - struct iterator_pair_traits : public base_container_traits + template + struct iterator_range_traits : public base_container_traits { }; diff --git a/include/boost/python/suite/indexing/iterator_pair.hpp b/include/boost/python/suite/indexing/iterator_range.hpp similarity index 70% rename from include/boost/python/suite/indexing/iterator_pair.hpp rename to include/boost/python/suite/indexing/iterator_range.hpp index 557047bb..4b29a1dd 100755 --- a/include/boost/python/suite/indexing/iterator_pair.hpp +++ b/include/boost/python/suite/indexing/iterator_range.hpp @@ -1,6 +1,4 @@ -// -*- mode:c++ -*- -// -// Header file iterator_pair.hpp +// Header file iterator_range.hpp // // Emulate an STL container using a pair of iterators. Doesn't support // insertion or deletion, for the obvious reasons. @@ -13,13 +11,14 @@ // // History // ======= -// 2003/ 9/ 9 rmg File creation +// 2003/ 9/ 9 rmg File creation as iterator_pair.hpp +// 2003/10/27 rmg Renamed iterator_range.hpp // // $Id$ // -#ifndef BOOST_PYTHON_INDEXING_ITERATOR_PAIR_HPP -#define BOOST_PYTHON_INDEXING_ITERATOR_PAIR_HPP +#ifndef BOOST_PYTHON_INDEXING_ITERATOR_RANGE_HPP +#define BOOST_PYTHON_INDEXING_ITERATOR_RANGE_HPP #include #include @@ -29,7 +28,7 @@ namespace boost { namespace python { namespace indexing { template - class iterator_pair + class iterator_range { private: typedef typename boost::call_traits::param_type iterator_param; @@ -45,7 +44,7 @@ namespace boost { namespace python { namespace indexing { typedef iterator const_iterator; // Can't tell what the const version of our iterator should - // be. The client code will have to instantiate iterator_pair + // be. The client code will have to instantiate iterator_range // directly with a const_iterator if that's what it wants. // Also can't provide: allocator_type, reverse_iterator or @@ -54,8 +53,8 @@ namespace boost { namespace python { namespace indexing { // reference and pointer if Iterator is itself a const_iterator. public: - iterator_pair (iterator_param, iterator_param); - iterator_pair (std::pair const &); + iterator_range (iterator_param, iterator_param); + iterator_range (std::pair const &); iterator begin() const; iterator end() const; @@ -72,7 +71,7 @@ namespace boost { namespace python { namespace indexing { }; template - iterator_pair::iterator_pair ( + iterator_range::iterator_range ( iterator_param begin, iterator_param end) : m_begin (begin) , m_end (end) @@ -80,37 +79,37 @@ namespace boost { namespace python { namespace indexing { } template - iterator_pair - ::iterator_pair (std::pair const &pair) + iterator_range + ::iterator_range (std::pair const &pair) : m_begin (pair.first) , m_end (pair.second) { } template - typename iterator_pair::iterator - iterator_pair::begin() const + typename iterator_range::iterator + iterator_range::begin() const { return m_begin; } template - typename iterator_pair::iterator - iterator_pair::end() const + typename iterator_range::iterator + iterator_range::end() const { return m_end; } template - typename iterator_pair::size_type - iterator_pair::size() const + typename iterator_range::size_type + iterator_range::size() const { return std::distance (begin(), end()); } template - typename iterator_pair::reference - iterator_pair::operator[](size_type index) const + typename iterator_range::reference + iterator_range::operator[](size_type index) const { iterator temp (begin()); std::advance (temp, index); @@ -118,13 +117,13 @@ namespace boost { namespace python { namespace indexing { } template - typename iterator_pair::reference - iterator_pair::at (size_type index) const + typename iterator_range::reference + iterator_range::at (size_type index) const { if (index >= size()) { throw std::out_of_range - (std::string ("iterator_pair: index out of range")); + (std::string ("iterator_range: index out of range")); } else @@ -144,4 +143,4 @@ namespace boost { namespace python { namespace indexing { } } } } -#endif // BOOST_PYTHON_INDEXING_ITERATOR_PAIR_HPP +#endif // BOOST_PYTHON_INDEXING_ITERATOR_RANGE_HPP diff --git a/test/test_array_ext.cpp b/test/test_array_ext.cpp index 718a434b..d75b8885 100755 --- a/test/test_array_ext.cpp +++ b/test/test_array_ext.cpp @@ -1,5 +1,3 @@ -// -*- mode:c++ -*- -// // Module test_array_ext.cpp // // Copyright (c) 2003 Raoul M. Gough @@ -18,7 +16,7 @@ #include "int_wrapper.hpp" #include -#include +#include #include #include #include @@ -28,23 +26,23 @@ bool int_wrapper::our_trace_flag = true; unsigned int_wrapper::our_object_counter = 0; -boost::python::indexing::iterator_pair get_array_plain() +boost::python::indexing::iterator_range get_array_plain() { static int array[] = { 8, 6, 4, 2, 1, 3, 5, 7, 0 }; - return boost::python::indexing::iterator_pair + return boost::python::indexing::iterator_range (boost::python::indexing::begin(array) , boost::python::indexing::end(array)); } -boost::python::indexing::iterator_pair get_array_wrap() +boost::python::indexing::iterator_range get_array_wrap() { static int_wrapper array[] = { int_wrapper(8), int_wrapper(6), int_wrapper(4), int_wrapper(2) , int_wrapper(1), int_wrapper(3), int_wrapper(5) , int_wrapper(7), int_wrapper(0) }; - return boost::python::indexing::iterator_pair + return boost::python::indexing::iterator_range (boost::python::indexing::begin(array) , boost::python::indexing::end(array)); } @@ -61,7 +59,7 @@ BOOST_PYTHON_MODULE(test_array_ext) .def ("__cmp__", compare) ; - typedef boost::python::indexing::iterator_pair Container1; + typedef boost::python::indexing::iterator_range Container1; boost::python::class_ ("Array", boost::python::init()) @@ -69,12 +67,12 @@ BOOST_PYTHON_MODULE(test_array_ext) boost::python::def ("get_array_plain", get_array_plain); - typedef boost::python::indexing::iterator_pair Container2; + typedef boost::python::indexing::iterator_range Container2; // reference_existing_object is safe in this case, because the array // is static, and we never manually destroy any array elements. There // is also no point in using return_internal_reference to extend the - // life of the iterator_pair object, since it has no influence on the + // life of the iterator_range object, since it has no influence on the // lifetimes of the array elements. boost::python::class_ ("Array_ref", boost::python::init())