diff --git a/include/boost/ptr_container/detail/void_ptr_iterator.hpp b/include/boost/ptr_container/detail/void_ptr_iterator.hpp index d73b5f8..9d00c67 100755 --- a/include/boost/ptr_container/detail/void_ptr_iterator.hpp +++ b/include/boost/ptr_container/detail/void_ptr_iterator.hpp @@ -20,8 +20,9 @@ #endif #include -#include -#include +//#include +//#include +#include #include #include #include @@ -32,6 +33,108 @@ namespace boost { namespace ptr_container_detail { + /* + template + < + class VoidIter, + class T + > + class void_ptr_iterator : public + boost::random_access_iterator_helper< void_ptr_iterator, + T*, std::ptrdiff_t, T**, T*&> + + { + typedef BOOST_DEDUCED_TYPENAME + mpl::if_< boost::is_const, + const void*, + void* >::type void_type; + public: + typedef VoidIter wrapped_type; + typedef T* value_type; + typedef T*& reference; + typedef std::ptrdiff_t Difference; + + private: + + VoidIter iter_; + + public: + void_ptr_iterator() : iter_() + { } + + void_ptr_iterator( VoidIter r ) : iter_(r) + { } + + // + // Remark: passing by value breaks vc7.1 + // + template< class MutableIterator, class MutableT > + void_ptr_iterator( const void_ptr_iterator& r ) + : iter_(r.base()) + { } + + VoidIter base() const + { + return iter_; + } + + + template< class MutableIterator, class MutableT > + void_ptr_iterator& operator=( void_ptr_iterator r ) + { + iter_ = r.base(); + } + + + reference operator*() const + { + return reinterpret_cast( const_cast( *iter_ ) ); + } + + bool operator==( void_ptr_iterator r ) const + { + return iter_ == r.iter_; + } + + bool operator<( void_ptr_iterator r ) const + { + return iter_ < r.iter_; + } + + void_ptr_iterator& operator++() + { + ++iter_; + return *this; + } + + void_ptr_iterator& operator--() + { + --iter_; + return *this; + } + + void_ptr_iterator& operator+=( Distance n ) + { + iter_ += n; + return *this; + } + + void_ptr_iterator& operator-=( Distance n ) + { + iter_ -= n; + return *this; + } + + + friend Distance operator-( const void_ptr_iterator& x, const void_ptr_iterator& y); + + difference_type distance_to( void_ptr_iterator r ) const + { + return r.iter_ - iter_; + } + + }; // class 'void_ptr_iterator' +*/ template < @@ -56,7 +159,7 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME iterator_difference::type difference_type; private: - + VoidIter iter_; public: @@ -86,7 +189,7 @@ namespace boost iter_ = r.base(); } */ - + private: friend class boost::iterator_core_access; @@ -122,7 +225,6 @@ namespace boost }; // class 'void_ptr_iterator' - /* template < diff --git a/include/boost/ptr_container/ptr_map_adapter.hpp b/include/boost/ptr_container/ptr_map_adapter.hpp index da8907b..8794e16 100755 --- a/include/boost/ptr_container/ptr_map_adapter.hpp +++ b/include/boost/ptr_container/ptr_map_adapter.hpp @@ -148,6 +148,8 @@ namespace boost reference; typedef BOOST_DEDUCED_TYPENAME base_type::value_type value_type; + typedef BOOST_DEDUCED_TYPENAME base_type::auto_type + auto_type; private: reference lookup( const key_type& key ) const @@ -432,6 +434,9 @@ namespace boost return this->single_transfer( first, last, from ); } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range, iterator >, @@ -440,6 +445,8 @@ namespace boost { return transfer( this->adl_begin(r), this->adl_end(r), from ); } + +#endif size_type transfer( ptr_map_adapter& from ) // basic { @@ -577,6 +584,9 @@ namespace boost return this->multi_transfer( first, last, from ); } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range, iterator >, @@ -586,6 +596,8 @@ namespace boost return transfer( this->adl_begin(r), this->adl_end(r), from ); } +#endif + void transfer( ptr_multimap_adapter& from ) // basic { transfer( from.begin(), from.end(), from ); diff --git a/include/boost/ptr_container/ptr_sequence_adapter.hpp b/include/boost/ptr_container/ptr_sequence_adapter.hpp index d4d6934..d2bb377 100755 --- a/include/boost/ptr_container/ptr_sequence_adapter.hpp +++ b/include/boost/ptr_container/ptr_sequence_adapter.hpp @@ -370,6 +370,8 @@ namespace boost iterator_category::type() ); } +#if BOOST_NO_SFINAE +#else template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< ptr_container_detail::is_pointer_or_integral >::type @@ -378,7 +380,7 @@ namespace boost insert( before, this->adl_begin(r), this->adl_end(r) ); } - +#endif /* auto_type release( size_type at ) @@ -418,6 +420,9 @@ namespace boost from.c_private().erase( object.base().base() ); // nothrow } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range, iterator > >::type @@ -425,6 +430,8 @@ namespace boost { transfer( before, this->adl_begin(r), this->adl_end(r), from ); } + +#endif void transfer( iterator before, ptr_sequence_adapter& from ) // strong { diff --git a/include/boost/ptr_container/ptr_set_adapter.hpp b/include/boost/ptr_container/ptr_set_adapter.hpp index 15ad7ba..4dbd866 100755 --- a/include/boost/ptr_container/ptr_set_adapter.hpp +++ b/include/boost/ptr_container/ptr_set_adapter.hpp @@ -325,6 +325,9 @@ namespace boost set_basic_clone_and_insert( first, last ); } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< ptr_container_detail::is_pointer_or_integral >::type @@ -332,6 +335,8 @@ namespace boost { insert( this->adl_begin(r), this->adl_end(r) ); } + +#endif bool transfer( iterator object, ptr_set_adapter& from ) // strong @@ -346,6 +351,9 @@ namespace boost return this->single_transfer( first, last, from ); } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range, iterator >, @@ -355,6 +363,7 @@ namespace boost return transfer( this->adl_begin(r), this->adl_end(r), from ); } +#endif size_type transfer( ptr_set_adapter& from ) // basic { @@ -452,6 +461,9 @@ namespace boost set_basic_clone_and_insert( first, last ); } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< ptr_container_detail::is_pointer_or_integral >::type @@ -460,6 +472,8 @@ namespace boost insert( this->adl_begin(r), this->adl_end(r) ); } +#endif + void transfer( iterator object, ptr_multiset_adapter& from ) // strong { @@ -473,6 +487,9 @@ namespace boost return this->multi_transfer( first, last, from ); } +#if BOOST_NO_SFINAE +#else + template< class Range > BOOST_DEDUCED_TYPENAME boost::disable_if< boost::is_same< Range, iterator >, size_type >::type @@ -481,6 +498,8 @@ namespace boost return transfer( this->adl_begin(r), this->adl_end(r), from ); } +#endif + void transfer( ptr_multiset_adapter& from ) // basic { transfer( from.begin(), from.end(), from ); diff --git a/test/associative_test_data.hpp b/test/associative_test_data.hpp index 0a81b3a..26fc186 100755 --- a/test/associative_test_data.hpp +++ b/test/associative_test_data.hpp @@ -46,13 +46,14 @@ void ptr_set_test() BOOST_DEDUCED_TYPENAME C::size_type s = c.size(); BOOST_DEDUCED_TYPENAME C::size_type s2 = c.max_size(); + hide_warning(s2); BOOST_CHECK_EQUAL( c.size(), s ); bool b = c.empty(); + hide_warning(b); BOOST_MESSAGE( "finished accessors test" ); T* t = new T; c.insert( c.end(), t ); -// c.insert( c.end(), T() ); c.insert( new T ); c3.insert( c.begin(), c.end() ); c.erase( c.begin() ); @@ -74,6 +75,11 @@ void ptr_set_test() c3.insert( new T ); c3.insert( new T ); BOOST_CHECK_EQUAL( c3.size(), 2u ); +#if BOOST_NO_SFINAE +#else + c3.insert( make_iterator_range( c3 ) ); + BOOST_CHECK_EQUAL( c3.size(), 4u ); +#endif c.transfer( c3.begin(), c3 ); BOOST_CHECK( c3.empty() == false ); c.transfer( c3.begin(), c3.end(), c3 ); @@ -82,6 +88,12 @@ void ptr_set_test() c3.transfer( c ); BOOST_CHECK( !c3.empty() ); BOOST_CHECK( c.empty() ); +#if BOOST_NO_SFINAE +#else + c.transfer( make_iterator_range( c3 ), c3 ); + BOOST_CHECK( !c.empty() ); + BOOST_CHECK( c3.empty() ); +#endif BOOST_MESSAGE( "finished transfer test" ); C c4; @@ -102,9 +114,6 @@ void ptr_set_test() sub = c.equal_range( T() ); csub = c2.equal_range( T() ); - //BOOST_CHECK_THROW( c.at( T() ), bad_ptr_container_operation ); - //BOOST_CHECK_THROW( c2.at( T() ), bad_ptr_container_operation ); - try { c.at( T() ); diff --git a/test/incomplete_type_test.cpp b/test/incomplete_type_test.cpp index ac0581b..b83608b 100755 --- a/test/incomplete_type_test.cpp +++ b/test/incomplete_type_test.cpp @@ -163,7 +163,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_incomplete ) ); diff --git a/test/indirect_fun.cpp b/test/indirect_fun.cpp index 6fb9823..197eca5 100755 --- a/test/indirect_fun.cpp +++ b/test/indirect_fun.cpp @@ -51,7 +51,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_fun ) ); diff --git a/test/iterator_test.cpp b/test/iterator_test.cpp index cb02270..394a45d 100755 --- a/test/iterator_test.cpp +++ b/test/iterator_test.cpp @@ -21,7 +21,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_iterator ) ); diff --git a/test/pointainer_speed.cpp b/test/pointainer_speed.cpp index 0a2bb9b..bf3a0e2 100755 --- a/test/pointainer_speed.cpp +++ b/test/pointainer_speed.cpp @@ -182,7 +182,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_speed ) ); diff --git a/test/ptr_array.cpp b/test/ptr_array.cpp index 9bd9cdd..038a1c8 100755 --- a/test/ptr_array.cpp +++ b/test/ptr_array.cpp @@ -147,7 +147,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_array ) ); diff --git a/test/ptr_container_adapter.cpp b/test/ptr_container_adapter.cpp index 0a38f56..fbd6459 100755 --- a/test/ptr_container_adapter.cpp +++ b/test/ptr_container_adapter.cpp @@ -48,7 +48,7 @@ using boost::unit_test_framework::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_container_adapter ) ); diff --git a/test/ptr_deque.cpp b/test/ptr_deque.cpp index 20d29bb..2a53c26 100755 --- a/test/ptr_deque.cpp +++ b/test/ptr_deque.cpp @@ -15,7 +15,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_ptr_deque ) ); diff --git a/test/ptr_list.cpp b/test/ptr_list.cpp index 0340648..53c1a8d 100755 --- a/test/ptr_list.cpp +++ b/test/ptr_list.cpp @@ -15,7 +15,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_list ) ); diff --git a/test/ptr_map.cpp b/test/ptr_map.cpp index ae0012e..418999e 100755 --- a/test/ptr_map.cpp +++ b/test/ptr_map.cpp @@ -65,8 +65,10 @@ void ptr_map_test() BOOST_DEDUCED_TYPENAME C::size_type s = c.size(); BOOST_DEDUCED_TYPENAME C::size_type s2 = c.max_size(); + hide_warning(s2); BOOST_CHECK_EQUAL( c.size(), s ); bool b = c.empty(); + hide_warning(b); BOOST_MESSAGE( "finished accessors test" ); a_key = get_next_key( a_key ); @@ -110,6 +112,13 @@ void ptr_map_test() c3.transfer( c ); BOOST_CHECK( !c3.empty() ); BOOST_CHECK( c.empty() ); +#if BOOST_NO_SFINAE +#else + c.transfer( make_iterator_range(c3), c3 ); + BOOST_CHECK( !c.empty() ); + BOOST_CHECK( c3.empty() ); + c3.transfer(c); +#endif BOOST_MESSAGE( "finished transfer test" ); BOOST_CHECK( !c3.empty() ); @@ -200,6 +209,7 @@ void test_map() if( is_null(i) ) BOOST_CHECK( false ); const string& ref = i.key(); + hide_warning(ref); int& ref2 = *i; ref2++; } @@ -210,7 +220,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_map ) ); diff --git a/test/ptr_map_adapter.cpp b/test/ptr_map_adapter.cpp index af4b5f1..c64d482 100755 --- a/test/ptr_map_adapter.cpp +++ b/test/ptr_map_adapter.cpp @@ -45,7 +45,7 @@ using boost::unit_test_framework::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_container_adapter ) ); diff --git a/test/ptr_set.cpp b/test/ptr_set.cpp index 3ee26f9..838bfe6 100755 --- a/test/ptr_set.cpp +++ b/test/ptr_set.cpp @@ -23,7 +23,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_set ) ); diff --git a/test/ptr_unordered_map.cpp b/test/ptr_unordered_map.cpp index 191ec7a..ca466a7 100755 --- a/test/ptr_unordered_map.cpp +++ b/test/ptr_unordered_map.cpp @@ -45,7 +45,7 @@ using boost::unit_test_framework::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_unordered_map ) ); diff --git a/test/ptr_unordered_set.cpp b/test/ptr_unordered_set.cpp index c4b03e6..aea382c 100755 --- a/test/ptr_unordered_set.cpp +++ b/test/ptr_unordered_set.cpp @@ -33,7 +33,7 @@ using boost::unit_test_framework::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_unordered_set ) ); diff --git a/test/ptr_vector.cpp b/test/ptr_vector.cpp index 0af3db2..4b5a44a 100755 --- a/test/ptr_vector.cpp +++ b/test/ptr_vector.cpp @@ -43,7 +43,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_ptr_vector ) ); diff --git a/test/sequence_test_data.hpp b/test/sequence_test_data.hpp index ff6f7a0..ec5166e 100755 --- a/test/sequence_test_data.hpp +++ b/test/sequence_test_data.hpp @@ -7,7 +7,6 @@ template< typename C, typename B, typename T > void reversible_container_test(); - template< typename C, typename B, typename T > void reversible_container_test() { @@ -28,9 +27,7 @@ void reversible_container_test() c.assign( c3.begin(), c3.end() ); BOOST_CHECK( c.size() == c3.size() ); - //c.assign( size, T() ); c.assign( c3 ); - //BOOST_CHECK( c.size() == size ); BOOST_MESSAGE( "finished construction test" ); BOOST_DEDUCED_TYPENAME C::allocator_type alloc = c.get_allocator(); @@ -55,29 +52,33 @@ void reversible_container_test() BOOST_MESSAGE( "finished iterator test" ); BOOST_DEDUCED_TYPENAME C::size_type s = c.size(); + hide_warning(s); BOOST_DEDUCED_TYPENAME C::size_type s2 = c.max_size(); - //c.resize( size, T() ); - //BOOST_CHECK( c.size() == size ); + hide_warning(s2); c.push_back( new T ); bool b = c.empty(); BOOST_CHECK( !c.empty() ); b = is_null( c.begin() ); BOOST_CHECK( b == false ); BOOST_DEDUCED_TYPENAME C::reference r = c.front(); + hide_warning(r); BOOST_DEDUCED_TYPENAME C::const_reference cr = c2.front(); + hide_warning(cr); BOOST_DEDUCED_TYPENAME C::reference r2 = c.back(); + hide_warning(r2); BOOST_DEDUCED_TYPENAME C::const_reference cr2 = c2.back(); + hide_warning(cr2); BOOST_MESSAGE( "finished accessors test" ); c.push_back( new T ); - //c.push_back( T() ); + c.pop_back(); c.insert( c.end(), new T ); - //c.insert( c.end(), T() ); - //c.insert( c.end(), size, T() ); - //c.insert( c.end(), make_iterator_range( c3 ) ); - // vs. + +#if BOOST_NO_SFINAE +#else c.insert( c.end(), c3 ); +#endif c3.insert( c3.end(), c.begin(), c.end() ); c.erase( c.begin() ); c3.erase( c3.begin(), c3.end() ); @@ -106,9 +107,12 @@ void reversible_container_test() c3.push_back( new T ); c.transfer( c.begin(), c3.begin(), c3 ); c.transfer( c.end(), c3.begin(), c3.end(), c3 ); - c.transfer( c.end(), boost::make_iterator_range( c3 ), c3 ); +#if BOOST_NO_SFINAE +#else + c.transfer( c.end(), boost::make_iterator_range( c3 ), c3 ); BOOST_CHECK( c3.empty() ); BOOST_CHECK( !c.empty() ); +#endif c3.transfer( c3.begin(), c ); BOOST_CHECK( !c3.empty() ); BOOST_CHECK( c.empty() ); diff --git a/test/simple_test.cpp b/test/simple_test.cpp index 8f540b6..d3733cd 100755 --- a/test/simple_test.cpp +++ b/test/simple_test.cpp @@ -82,7 +82,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &simple_test ) ); diff --git a/test/test_data.hpp b/test/test_data.hpp index 60e78d8..b579f8b 100755 --- a/test/test_data.hpp +++ b/test/test_data.hpp @@ -197,5 +197,10 @@ ostream& operator<<( ostream& out, const Value& v ) return out << v.name() << " "; } - +// +// used to hide "unused variable" warnings +// +template< class T > +void hide_warning( T& r ) +{ } diff --git a/test/tree_test.cpp b/test/tree_test.cpp index 319d3d6..b3edafc 100755 --- a/test/tree_test.cpp +++ b/test/tree_test.cpp @@ -260,7 +260,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_tree ) ); diff --git a/test/xml_tree_test.cpp b/test/xml_tree_test.cpp index 8c03aba..08b0492 100755 --- a/test/xml_tree_test.cpp +++ b/test/xml_tree_test.cpp @@ -163,7 +163,7 @@ using boost::unit_test::test_suite; test_suite* init_unit_test_suite( int argc, char* argv[] ) { - test_suite* test = BOOST_TEST_SUITE( "Smart Container Test Suite" ); + test_suite* test = BOOST_TEST_SUITE( "Pointer Container Test Suite" ); test->add( BOOST_TEST_CASE( &test_tree ) );