Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50083 - in sandbox/itl: boost/itl libs/itl/example/boost_party
From: afojgo_at_[hidden]
Date: 2008-12-03 03:13:25


Author: jofaber
Date: 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
New Revision: 50083
URL: http://svn.boost.org/trac/boost/changeset/50083

Log:
Refactored: Removed Nasonov accessor again. Fallback version for Compare functor refactoring. Stable {msvc-9.0}
Text files modified:
   sandbox/itl/boost/itl/interval_base_map.hpp | 58 ++-------------------------------------
   sandbox/itl/boost/itl/interval_base_set.hpp | 40 ++++-----------------------
   sandbox/itl/boost/itl/interval_set.hpp | 4 ++
   sandbox/itl/boost/itl/notate.hpp | 6 ++--
   sandbox/itl/boost/itl/separate_interval_set.hpp | 4 ++
   sandbox/itl/boost/itl/split_interval_set.hpp | 4 ++
   sandbox/itl/libs/itl/example/boost_party/boost_party.cpp | 4 ++
   7 files changed, 25 insertions(+), 95 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-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -226,59 +226,7 @@
     typedef typename itl::map<DomainT,CodomainT,
                               Traits,Compare,Combine,Alloc> atomized_type;
 //@}
-
-private:
- struct access : SubType
- {
- static bool contains(const SubType& subject, const typename SubType::value_type& operand)
- {
- bool (SubType::*fp)(const typename SubType::value_type&)const = &access::contains_;
- return (subject.*fp)(operand);
- }
-
- template<class OperandT, class Combiner>
- static void add(SubType& subject, const OperandT& operand, const Combiner& combine)
- {
- void (SubType::*fp)(const OperandT&, const Combiner&) = &access::add_;
- (subject.*fp)(operand, combine);
- }
-
- template<class OperandT, class Combiner>
- static void subtract(SubType& subject, const OperandT& operand, const Combiner& combine)
- {
- void (SubType::*fp)(const OperandT&, const Combiner&) = &access::subtract_;
- (subject.*fp)(operand, combine);
- }
-
- template<class OperandT>
- static void add(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::add_;
- (subject.*fp)(operand);
- }
-
- template<class OperandT>
- static void subtract(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::subtract_;
- (subject.*fp)(operand);
- }
-
- template<class OperandT>
- static void insert(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::insert_;
- (subject.*fp)(operand);
- }
-
- template<class OperandT>
- static void erase(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::erase_;
- (subject.*fp)(operand);
- }
- };
-
+
 public:
     inline static bool has_symmetric_difference()
     { return is_set<codomain_type>::value || !traits::absorbs_neutrons || traits::emits_neutrons; }
@@ -548,7 +496,7 @@
     */
     SubType& insert(const base_pair_type& x)
     {
- access::insert(*that(), value_type(interval_type(x.key), x.data) );
+ that()->insert(value_type(interval_type(x.key), x.data));
         return *that();
     }
 
@@ -564,7 +512,7 @@
         \c insert(x) is equivalent to \c add<inplace_identity>(x)
     */
     SubType& insert(const value_type& x)
- { access::insert(*that(), x); return *that(); }
+ { that()->insert_(x); return *that(); }
 
     /// Erase a base value pair from the map
     /** Erase a base value pair <tt>x=(k,y)</tt>.

Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -173,34 +173,6 @@
     /// const_iterator for iteration over intervals
     typedef typename ImplSetT::const_reverse_iterator const_reverse_iterator;
 
-private:
- /** access is a technical class that makes protected members of derived classes
- SubType accessible for direct call from the base class. Accessing via
- fuction pointers has been proposed by Alexander Nasonov 2005:
- http://accu.org/index.php/journals/296.
- */
- struct access : SubType
- {
- static bool contains(const SubType& subject, const typename SubType::value_type& operand)
- {
- bool (SubType::*fp)(const typename SubType::value_type&)const = &access::contains_;
- return (subject.*fp)(operand);
- }
-
- static void add(SubType& subject, const typename SubType::value_type& operand)
- {
- void (SubType::*fp)(const typename SubType::value_type&) = &access::add_;
- (subject.*fp)(operand);
- }
-
- static void subtract(SubType& subject, const typename SubType::value_type& operand)
- {
- void (SubType::*fp)(const typename SubType::value_type&) = &access::subtract_;
- (subject.*fp)(operand);
- }
-
- };
-
 public:
     // B: Constructors, destructors, assignment
     /// Default constructor for the empty set
@@ -232,11 +204,11 @@
 
     /// Does the container contain the element \c x
     bool contains(const DomainT& x)const
- { return access::contains(*that(), interval_type(x)); }
+ { return that()->contains_(interval_type(x)); }
 
     /// Does the container contain the interval x
     bool contains(const interval_type& x)const
- { return access::contains(*that(), x); }
+ { return that()->contains_(x); }
 
     /** Does <tt>*this</tt> container contain <tt>sub</tt>? */
     bool contains(const interval_base_set& sub)const
@@ -279,11 +251,11 @@
 
     /// Add a single element \c x to the set
     SubType& add(const DomainT& x)
- { access::add(*that(), interval_type(x)); return *that(); }
+ { that()->add_(interval_type(x)); return *that(); }
 
     /// Add an interval of elements \c x to the set
     SubType& add(const value_type& x)
- { access::add(*that(), x); return *that(); }
+ { that()->add_(x); return *that(); }
 
 //@}
 
@@ -293,11 +265,11 @@
 
     /// Subtract a single element \c x from the set
     SubType& subtract(const DomainT& x)
- { access::subtract(*that(), interval_type(x)); return *that(); }
+ { that()->subtract_(interval_type(x)); return *that(); }
 
     /// Subtract an interval of elements \c x from the set
     SubType& subtract(const value_type& x)
- { access::subtract(*that(), x); return *that(); }
+ { that()->subtract_(x); return *that(); }
 
     ///// Subtract a single element \c x from the set
     //interval_base_set& operator -= (const DomainT& x)

Modified: sandbox/itl/boost/itl/interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_set.hpp 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -203,7 +203,9 @@
             this->add(*it);
     }
 
-protected:
+private:
+ friend class base_type;
+
     /// Does the set contain the interval <tt>x</tt>?
     bool contains_(const interval_type& x)const;
 

Modified: sandbox/itl/boost/itl/notate.hpp
==============================================================================
--- sandbox/itl/boost/itl/notate.hpp (original)
+++ sandbox/itl/boost/itl/notate.hpp 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -77,18 +77,18 @@
 // (4) Being able to check template template parameter variants against
 // template type parameter variants.
 
-#define ITL_USE_COMBINE_TEMPLATE
+//#define ITL_USE_COMBINE_TEMPLATE_TEMPLATE
 
 //------------------------------------------------------------------------------
 #define ITL_COMPARE template<class>class
 #define ITL_COMPARE_DOMAIN(itl_compare, domain_type) itl_compare<domain_type>
 
 //------------------------------------------------------------------------------
-#ifdef ITL_USE_COMBINE_TEMPLATE
+#ifdef ITL_USE_COMBINE_TEMPLATE_TEMPLATE
 #define ITL_COMBINE template<class>class
 #define ITL_COMBINE_CODOMAIN(itl_combine, codomain_type) itl_combine<codomain_type>
 #define ITL_INPLACE_PLUS(codomain_type) itl::inplace_plus
-#else
+#else//ITL_USE_COMBINE_TEMPLATE_TYPE
 #define ITL_COMBINE class
 #define ITL_COMBINE_CODOMAIN(itl_combine, codomain_type) itl_combine
 #define ITL_INPLACE_PLUS(codomain_type) itl::inplace_plus<codomain_type>

Modified: sandbox/itl/boost/itl/separate_interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/separate_interval_set.hpp (original)
+++ sandbox/itl/boost/itl/separate_interval_set.hpp 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -165,7 +165,9 @@
             this->_set.insert(*it);
     }
 
-protected:
+private:
+ friend class base_type;
+
     /// Does the set contain the interval <tt>x</tt>?
     bool contains_(const interval_type& x)const;
 

Modified: sandbox/itl/boost/itl/split_interval_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/split_interval_set.hpp (original)
+++ sandbox/itl/boost/itl/split_interval_set.hpp 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -182,7 +182,9 @@
                 this->_set.insert(*it);
         }
         
- protected:
+ private:
+ friend class base_type;
+
         /// Does the set contain the interval <tt>x</tt>?
         bool contains_(const interval_type& x)const;
 

Modified: sandbox/itl/libs/itl/example/boost_party/boost_party.cpp
==============================================================================
--- sandbox/itl/libs/itl/example/boost_party/boost_party.cpp (original)
+++ sandbox/itl/libs/itl/example/boost_party/boost_party.cpp 2008-12-03 03:13:24 EST (Wed, 03 Dec 2008)
@@ -68,7 +68,11 @@
 typedef interval_map<ptime, GuestSetT> BoostPartyAttendenceHistoryT;
 
 // A party's height shall be defined as the maximum height of all guests ;-)
+#ifdef ITL_USE_COMBINE_TEMPLATE_TEMPLATE
 typedef interval_map<ptime, int, neutron_absorber, interval, less, inplace_max > BoostPartyHeightHistoryT;
+#else
+typedef interval_map<ptime, int, neutron_absorber, interval, less, inplace_max<int> > BoostPartyHeightHistoryT;
+#endif
 
 void boost_party()
 {


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