Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49623 - in sandbox/itl: boost/itl libs/itl/test/test_interval_map_mixed
From: afojgo_at_[hidden]
Date: 2008-11-07 09:20:43


Author: jofaber
Date: 2008-11-07 09:20:42 EST (Fri, 07 Nov 2008)
New Revision: 49623
URL: http://svn.boost.org/trac/boost/changeset/49623

Log:
Refactored Predicate passing for erase_if and assign_if. Prdicates are now adaptable functors. Stable {msvc-9.0}
Text files modified:
   sandbox/itl/boost/itl/interval_base_map.hpp | 13 +++++++------
   sandbox/itl/boost/itl/map.hpp | 22 +++++++++++-----------
   sandbox/itl/boost/itl/set.hpp | 20 ++++++++++----------
   sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp | 2 +-
   4 files changed, 29 insertions(+), 28 deletions(-)

Modified: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2008-11-07 09:20:42 EST (Fri, 07 Nov 2008)
@@ -691,7 +691,7 @@
     {
         //content_is_neutron<key_type, data_type> neutron_dropper;
         if(!Traits::absorbs_neutrons)
- erase_if<content_is_neutron>();
+ erase_if(content_is_neutron<value_type>());
     }
 
     /// Copies this map into a neutron_absorber type.
@@ -767,13 +767,14 @@
     */
 //@{
     /// Remove all elements where property <tt>p</tt> holds, keep all others
- template<template<class>class Predicate>
- interval_base_map& erase_if(){ _map.erase_if<Predicate>(); return *this; }
+ template<class Predicate>
+ interval_base_map& erase_if(const Predicate& pred)
+ { _map.erase_if(pred); return *this; }
 
     /// Copy all elements if property <tt>p</tt> holds
- template<template<class>class Predicate>
- interval_base_map& assign_if(const interval_base_map& src)
- { _map.assign_if<Predicate>(src._map); return *this; }
+ template<class Predicate>
+ interval_base_map& assign_if(const interval_base_map& src, const Predicate& pred)
+ { _map.assign_if(src._map, pred); return *this; }
 
 //@}
 

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2008-11-07 09:20:42 EST (Fri, 07 Nov 2008)
@@ -293,18 +293,18 @@
         {
             //content_is_neutron<key_type, data_type> neutron_dropper;
             if(!Traits::absorbs_neutrons)
- erase_if<content_is_neutron>();
+ erase_if(content_is_neutron<value_type>());
         }
 
         /** Erase the elements in *this map to which property \c hasProperty applies.
         Keep all the rest. */
- template<template<class>class Predicate>
- map& erase_if();
+ template<class Predicate>
+ map& erase_if(const Predicate&);
 
         /** Copy the elements in map \c src to which property \c hasProperty applies
         into \c *this map. */
- template<template<class>class Predicate>
- map& assign_if(const map& src);
+ template<class Predicate>
+ map& assign_if(const map& src, const Predicate&);
 
         /** Represent this map as string */
         std::string as_string()const;
@@ -461,13 +461,13 @@
     }
 
     template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
- template<template<class>class Predicate>
+ template<class Predicate>
     map<KeyT,DataT,Traits,Compare,Alloc>& map<KeyT,DataT,Traits,Compare,Alloc>
- ::erase_if()
+ ::erase_if(const Predicate& pred)
     {
         iterator it = begin();
         while(it != end())
- if(Predicate<value_type>()(*it))
+ if(pred(*it))
                 erase(it++);
             else ++it;
         return *this;
@@ -475,14 +475,14 @@
 
 
     template <typename KeyT, typename DataT, class Traits, template<class>class Compare, template<class>class Alloc>
- template<template<class>class Predicate>
+ template<class Predicate>
     map<KeyT,DataT,Traits,Compare,Alloc>& map<KeyT,DataT,Traits,Compare,Alloc>
- ::assign_if(const map<KeyT,DataT,Traits,Compare,Alloc>& src)
+ ::assign_if(const map<KeyT,DataT,Traits,Compare,Alloc>& src, const Predicate& pred)
     {
         clear();
         const_iterator it = src.begin();
         while(it != src.end()) {
- if(Predicate<value_type>(*it))
+ if(pred(*it))
                 add(*it++);
         }
         return *this;

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2008-11-07 09:20:42 EST (Fri, 07 Nov 2008)
@@ -198,13 +198,13 @@
 
         /** Erase the elements in *this set to which property \c hasProperty applies.
         Keep all the rest. */
- template<template<class>class Predicate>
- set& erase_if();
+ template<class Predicate>
+ set& erase_if(const Predicate&);
 
         /** Copy the elements in set \c src to which property \c hasProperty applies
             into \c *this set. */
- template<template<class>class Predicate>
- set& assign_if(const set& src);
+ template<class Predicate>
+ set& assign_if(const set& src, const Predicate&);
 
         /** Represent this set as a string */
         std::string as_string(const char* sep = " ")const;
@@ -282,13 +282,13 @@
 
 
     template <typename KeyT, template<class>class Compare, template<class>class Alloc>
- template<template<class>class Predicate>
+ template<class Predicate>
     set<KeyT,Compare,Alloc>& set<KeyT,Compare,Alloc>
- ::erase_if()
+ ::erase_if(const Predicate& pred)
     {
         iterator it = begin();
         while(it != end())
- if(Predicate<value_type>(*it))
+ if(pred(*it))
                 erase(it++);
             else ++it;
         return *this;
@@ -296,14 +296,14 @@
     }
 
     template <typename KeyT, template<class>class Compare, template<class>class Alloc>
- template<template<class>class Predicate>
+ template<class Predicate>
     set<KeyT,Compare,Alloc>& set<KeyT,Compare,Alloc>
- ::assign_if(const set<KeyT,Compare,Alloc>& src)
+ ::assign_if(const set<KeyT,Compare,Alloc>& src, const Predicate& pred)
     {
         clear();
         const_iterator it = src.begin();
         while(it != src.end()) {
- if(Predicate<value_type>(*it))
+ if(pred(*it))
                 add(*it++);
         }
         return *this;

Modified: sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp 2008-11-07 09:20:42 EST (Fri, 07 Nov 2008)
@@ -1168,7 +1168,7 @@
     split_A.add(I0_3D_1).add(I4_4I_1).add(I6_6I_1);
     split_B.add(I4_4I_1).add(I6_6I_1);
 
- split_A.template erase_if<size_greater_1>();
+ split_A.erase_if(size_greater_1<typename SplitIntervalMapT::value_type>());
 
     BOOST_CHECK_EQUAL( split_A, split_B );
 }


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