Boost logo

Boost-Commit :

From: jmcintyre_at_[hidden]
Date: 2007-08-22 21:40:47


Author: jared
Date: 2007-08-22 21:40:46 EDT (Wed, 22 Aug 2007)
New Revision: 38861
URL: http://svn.boost.org/trac/boost/changeset/38861

Log:
Remove an an unnecessary template parameter to the map key and value iterator adapters.
Text files modified:
   sandbox/pinhole/boost/pinhole/map_key_value_iterators.h | 146 +++++++++++++++++++--------------------
   sandbox/pinhole/boost/pinhole/property_group.h | 24 +++---
   sandbox/pinhole/boost/pinhole/property_manager.h | 26 +++---
   3 files changed, 96 insertions(+), 100 deletions(-)

Modified: sandbox/pinhole/boost/pinhole/map_key_value_iterators.h
==============================================================================
--- sandbox/pinhole/boost/pinhole/map_key_value_iterators.h (original)
+++ sandbox/pinhole/boost/pinhole/map_key_value_iterators.h 2007-08-22 21:40:46 EDT (Wed, 22 Aug 2007)
@@ -24,106 +24,102 @@
 
 namespace boost { namespace pinhole
 {
- template <class Reference, class Iterator>
- class map_key_iterator;
-
- namespace map_key_iterator_detail
- {
- template <class Reference, class Iterator>
- struct iterator_base
- {
- typedef boost::iterator_adaptor<
- map_key_iterator<Reference, Iterator>
- , Iterator // Base
- , boost::use_default // Value
- , boost::use_default//boost::forward_traversal_tag // CategoryOrTraversal
- , Reference
- > type;
- };
- }
-
     /** Iterates over all the keys in a map. */
- template <class Reference, class Iterator>
+ template <class Iterator>
     class map_key_iterator
- : public map_key_iterator_detail::iterator_base<Reference, Iterator>::type
+ : public boost::iterator_adaptor<
+ map_key_iterator<Iterator>
+ , Iterator
+ , boost::use_default
+ , boost::use_default
+ , typename std::iterator_traits<Iterator>::value_type::first_type
+ >
     {
- private:
- struct enabler {}; // a private type avoids misuse
-
- typedef typename map_key_iterator_detail::iterator_base<
- Reference, Iterator
- >::type super_t;
-
- friend class iterator_core_access;
-
- public:
- map_key_iterator() { }
-
- map_key_iterator( Iterator x, Iterator end = Iterator()) : super_t(x) { }
+ private:
+ typedef typename std::iterator_traits<Iterator>::value_type::first_type Reference;
 
+ struct enabler {}; // a private type avoids misuse
+
+ friend class boost::iterator_core_access;
+
+ public:
+ map_key_iterator() :
+ map_key_iterator::iterator_adaptor_() { }
+
+ explicit map_key_iterator( Iterator x, Iterator end = Iterator()) :
+ map_key_iterator::iterator_adaptor_(x) { }
+
+ template <class other_iterator>
+ map_key_iterator(
+ map_key_iterator<other_iterator> const& other
+ , typename boost::enable_if<
+ boost::is_convertible<other_iterator*, Iterator*>
+ , enabler
+ >::type = enabler()
+ )
+ : map_key_iterator::iterator_adaptor_(other.base()) {}
+
         Reference dereference() const
         {
             return (*this->base()).first;
         }
     };
-
+
     /** Factory for creating map_key_iterator iterators. */
- template <class Reference, class Iterator>
- map_key_iterator<Reference, Iterator>
+ template <class Iterator>
+ map_key_iterator<Iterator>
         make_map_key_iterator(Iterator x, Iterator end = Iterator())
     {
- return map_key_iterator<Reference,Iterator>(x,end);
+ return map_key_iterator<Iterator>(x,end);
     }
 
- template <class Reference, class Iterator>
- class map_value_iterator;
-
- namespace map_value_iterator_detail
- {
- template <class Reference, class Iterator>
- struct iterator_base
- {
- typedef boost::iterator_adaptor<
- map_value_iterator<Reference, Iterator>
- , Iterator // Base
- , boost::use_default // Value
- , boost::use_default//boost::forward_traversal_tag // CategoryOrTraversal
- , Reference
- > type;
- };
- }
-
- /** Iterates over all the keys in a map. */
- template <class Reference, class Iterator>
+ /** Iterates over all values in a map. */
+ template <class Iterator>
     class map_value_iterator
- : public map_value_iterator_detail::iterator_base<Reference, Iterator>::type
+ : public boost::iterator_adaptor<
+ map_value_iterator<Iterator>
+ , Iterator
+ , boost::use_default
+ , boost::use_default
+ , typename std::iterator_traits<Iterator>::value_type::second_type
+ >
     {
- private:
- struct enabler {}; // a private type avoids misuse
+ private:
+ typedef typename std::iterator_traits<Iterator>::value_type::second_type Reference;
+
+ struct enabler {}; // a private type avoids misuse
+
+ friend class boost::iterator_core_access;
+
+ public:
+ map_value_iterator() :
+ map_value_iterator::iterator_adaptor_() { }
+
+ map_value_iterator( Iterator x, Iterator end = Iterator()) :
+ map_value_iterator::iterator_adaptor_(x) { }
+
+ template <class other_iterator>
+ map_value_iterator(
+ map_value_iterator<other_iterator> const& other
+ , typename boost::enable_if<
+ boost::is_convertible<other_iterator*, Iterator*>
+ , enabler
+ >::type = enabler()
+ )
+ : map_value_iterator::iterator_adaptor_(other.base()) {}
         
- typedef typename map_value_iterator_detail::iterator_base<
- Reference, Iterator
- >::type super_t;
-
- friend class iterator_core_access;
-
- public:
- map_value_iterator() { }
-
- map_value_iterator( Iterator x, Iterator end = Iterator()) : super_t(x) { }
-
         Reference dereference() const
         {
             return (*this->base()).second;
         }
     };
-
+
     /** Factory for creating map_value_iterator iterators. */
- template <class Reference, class Iterator>
- map_value_iterator<Reference, Iterator>
+ template <class Iterator>
+ map_value_iterator<Iterator>
         make_map_value_iterator(Iterator x, Iterator end = Iterator())
     {
- return map_value_iterator<Reference,Iterator>(x,end);
+ return map_value_iterator<Iterator>(x,end);
     }
 }}
 

Modified: sandbox/pinhole/boost/pinhole/property_group.h
==============================================================================
--- sandbox/pinhole/boost/pinhole/property_group.h (original)
+++ sandbox/pinhole/boost/pinhole/property_group.h 2007-08-22 21:40:46 EDT (Wed, 22 Aug 2007)
@@ -244,15 +244,15 @@
         /** @name Properties */
         //@{
             typedef property_collection::size_type prop_size_type;
- typedef map_key_iterator<std::string, property_collection::iterator> prop_iterator;
- typedef map_key_iterator<std::string, property_collection::const_iterator> const_prop_iterator;
+ typedef map_key_iterator<property_collection::iterator> prop_iterator;
+ typedef map_key_iterator<property_collection::const_iterator> const_prop_iterator;
 
             /**
              * Retrieves an iterator pointing to the name of the first property.
              */
             prop_iterator prop_begin()
             {
- return make_map_key_iterator<string>( m_properties.begin() );
+ return prop_iterator( m_properties.begin() );
             }
 
             /**
@@ -260,7 +260,7 @@
              */
             const_prop_iterator prop_begin() const
             {
- return make_map_key_iterator<string>( m_properties.begin() );
+ return const_prop_iterator( m_properties.begin() );
             }
 
             /**
@@ -268,7 +268,7 @@
              */
             prop_iterator prop_end()
             {
- return make_map_key_iterator<string>( m_properties.end() );
+ return prop_iterator( m_properties.end() );
             }
 
             /**
@@ -276,7 +276,7 @@
              */
             const_prop_iterator prop_end() const
             {
- return make_map_key_iterator<string>( m_properties.end() );
+ return const_prop_iterator( m_properties.end() );
             }
 
             /**
@@ -490,15 +490,15 @@
         /** @name Actions */
         //@{
             typedef action_collection::size_type action_size_type;
- typedef map_key_iterator<std::string, action_collection::iterator> action_iterator;
- typedef map_key_iterator<std::string, action_collection::const_iterator> const_action_iterator;
+ typedef map_key_iterator<action_collection::iterator> action_iterator;
+ typedef map_key_iterator<action_collection::const_iterator> const_action_iterator;
 
             /**
              * Retrieves an iterator pointing to the name of the first property.
              */
             action_iterator action_begin()
             {
- return make_map_key_iterator<string>( m_actions.begin() );
+ return action_iterator( m_actions.begin() );
             }
 
             /**
@@ -506,7 +506,7 @@
              */
             const_action_iterator action_begin() const
             {
- return make_map_key_iterator<string>( m_actions.begin() );
+ return const_action_iterator( m_actions.begin() );
             }
 
             /**
@@ -514,7 +514,7 @@
              */
             action_iterator action_end()
             {
- return make_map_key_iterator<string>( m_actions.end() );
+ return action_iterator( m_actions.end() );
             }
 
             /**
@@ -522,7 +522,7 @@
              */
             const_action_iterator action_end() const
             {
- return make_map_key_iterator<string>( m_actions.end() );
+ return const_action_iterator( m_actions.end() );
             }
 
             /**

Modified: sandbox/pinhole/boost/pinhole/property_manager.h
==============================================================================
--- sandbox/pinhole/boost/pinhole/property_manager.h (original)
+++ sandbox/pinhole/boost/pinhole/property_manager.h 2007-08-22 21:40:46 EDT (Wed, 22 Aug 2007)
@@ -78,8 +78,8 @@
         
     public:
         typedef multimap<string, property_group*> category_to_property_group_map;
- typedef map_value_iterator<property_group*, category_to_property_group_map::iterator> iterator;
- typedef map_value_iterator<property_group*, category_to_property_group_map::const_iterator> const_iterator;
+ typedef map_value_iterator<category_to_property_group_map::iterator> iterator;
+ typedef map_value_iterator<category_to_property_group_map::const_iterator> const_iterator;
         
         static property_manager* instance()
         {
@@ -113,7 +113,7 @@
     public:
         virtual ~property_manager()
         {
- category_to_property_group_map::iterator itr = m_property_group_collection.begin();
+ category_to_property_group_map::iterator itr = m_property_group_collection.begin();
             category_to_property_group_map::iterator itr_end = m_property_group_collection.end();
             for( ; itr != itr_end; ++itr )
             {
@@ -127,8 +127,8 @@
          */
         iterator begin()
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.lower_bound("All"),
- m_property_group_collection.upper_bound("All") );
+ return iterator( m_property_group_collection.lower_bound("All"),
+ m_property_group_collection.upper_bound("All") );
         }
         
         /**
@@ -136,8 +136,8 @@
          */
         const_iterator begin() const
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.lower_bound("All"),
- m_property_group_collection.upper_bound("All") );
+ return const_iterator( m_property_group_collection.lower_bound("All"),
+ m_property_group_collection.upper_bound("All") );
         }
         
         /**
@@ -145,7 +145,7 @@
          */
         iterator end()
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.upper_bound("All") );
+ return iterator( m_property_group_collection.upper_bound("All") );
         }
         
         /**
@@ -153,7 +153,7 @@
          */
         const_iterator end() const
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.upper_bound("All") );
+ return const_iterator( m_property_group_collection.upper_bound("All") );
         }
         
         /**
@@ -169,7 +169,7 @@
          */
         iterator begin(const string& strCategory)
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.lower_bound(strCategory) );
+ return iterator( m_property_group_collection.lower_bound(strCategory) );
         }
         
         /**
@@ -177,7 +177,7 @@
          */
         const_iterator begin(const string& strCategory) const
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.lower_bound(strCategory) );
+ return const_iterator( m_property_group_collection.lower_bound(strCategory) );
         }
         
         /**
@@ -185,7 +185,7 @@
          */
         iterator end(const string& strCategory)
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.upper_bound(strCategory) );
+ return iterator( m_property_group_collection.upper_bound(strCategory) );
         }
         
         /**
@@ -193,7 +193,7 @@
          */
         const_iterator end(const string& strCategory) const
         {
- return make_map_value_iterator<property_group*>( m_property_group_collection.upper_bound(strCategory) );
+ return const_iterator( m_property_group_collection.upper_bound(strCategory) );
         }
         
         /**


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk