Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69964 - in sandbox/icl/boost/icl: . concept
From: afojgo_at_[hidden]
Date: 2011-03-13 16:24:03


Author: jofaber
Date: 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
New Revision: 69964
URL: http://svn.boost.org/trac/boost/changeset/69964

Log:
Fixed standard conformance issues, detected by Doug Gregor March-05.

Added:
   sandbox/icl/boost/icl/concept/interval_associator_base.hpp (contents, props changed)
Properties modified:
   sandbox/icl/boost/icl/ (props changed)
Text files modified:
   sandbox/icl/boost/icl/concept/element_associator.hpp | 6 ++++++
   sandbox/icl/boost/icl/concept/element_map.hpp | 7 -------
   sandbox/icl/boost/icl/concept/element_set.hpp | 7 -------
   sandbox/icl/boost/icl/concept/interval_associator.hpp | 2 +-
   sandbox/icl/boost/icl/concept/interval_map.hpp | 4 ++--
   5 files changed, 9 insertions(+), 17 deletions(-)

Modified: sandbox/icl/boost/icl/concept/element_associator.hpp
==============================================================================
--- sandbox/icl/boost/icl/concept/element_associator.hpp (original)
+++ sandbox/icl/boost/icl/concept/element_associator.hpp 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
@@ -422,6 +422,12 @@
     return object;
 }
 
+template<class Type>
+inline typename enable_if<is_associative_element_container<Type>, Type>::type
+operator & (Type object, const Type& operand)
+{
+ return object &= operand;
+}
 //------------------------------------------------------------------------------
 
 template<class Type, class CoType>

Modified: sandbox/icl/boost/icl/concept/element_map.hpp
==============================================================================
--- sandbox/icl/boost/icl/concept/element_map.hpp (original)
+++ sandbox/icl/boost/icl/concept/element_map.hpp 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
@@ -284,13 +284,6 @@
 
 template<class Type>
 inline typename enable_if<is_element_map<Type>, Type>::type
-operator & (Type object, const Type& operand)
-{
- return object &= operand;
-}
-
-template<class Type>
-inline typename enable_if<is_element_map<Type>, Type>::type
 operator & (Type object, const typename Type::key_object_type& operand)
 {
     return object &= operand;

Modified: sandbox/icl/boost/icl/concept/element_set.hpp
==============================================================================
--- sandbox/icl/boost/icl/concept/element_set.hpp (original)
+++ sandbox/icl/boost/icl/concept/element_set.hpp 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
@@ -60,13 +60,6 @@
 //= Intersection
 //==============================================================================
 template<class Type>
-inline typename enable_if<is_element_set<Type>, Type>::type
-operator & (Type object, const Type& operand)
-{
- return object &= operand;
-}
-
-template<class Type>
 inline typename enable_if<is_element_set<Type>, bool>::type
 intersects(const Type& object, const typename Type::key_type& operand)
 {

Modified: sandbox/icl/boost/icl/concept/interval_associator.hpp
==============================================================================
--- sandbox/icl/boost/icl/concept/interval_associator.hpp (original)
+++ sandbox/icl/boost/icl/concept/interval_associator.hpp 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
@@ -662,7 +662,7 @@
                    bool>::type
 intersects(const Type& left, const CoType& right)
 {
- return left.find(right) != left.end();
+ return icl::find(left, right) != left.end();
 }
 
 

Added: sandbox/icl/boost/icl/concept/interval_associator_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/icl/boost/icl/concept/interval_associator_base.hpp 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
@@ -0,0 +1,149 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2011-2011: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+#ifndef BOOST_ICL_CONCEPT_INTERVAL_ASSOCIATOR_BASE_HPP_JOFA_110301
+#define BOOST_ICL_CONCEPT_INTERVAL_ASSOCIATOR_BASE_HPP_JOFA_110301
+
+#include <boost/icl/type_traits/domain_type_of.hpp>
+#include <boost/icl/type_traits/interval_type_of.hpp>
+#include <boost/icl/type_traits/is_combinable.hpp>
+#include <boost/icl/concept/set_value.hpp>
+#include <boost/icl/concept/map_value.hpp>
+#include <boost/icl/concept/interval.hpp>
+
+namespace boost{ namespace icl
+{
+
+//==============================================================================
+//= Selection<IntervalSet|IntervalMap>
+//==============================================================================
+template<class Type> inline
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_discrete<typename domain_type_of<Type>::type>
+ >
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename domain_type_of<Type>::type& key_val)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::interval_type interval_type;
+ return object.find(icl::detail::unit_trail<interval_type>(key_val));
+}
+
+template<class Type> inline
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_continuous<typename domain_type_of<Type>::type>
+ , has_dynamic_bounds<typename interval_type_of<Type>::type>
+ >
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename domain_type_of<Type>::type& key_val)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::interval_type interval_type;
+ return object.find(icl::singleton<interval_type>(key_val));
+}
+
+template<class Type> inline
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_continuous<typename domain_type_of<Type>::type>
+ , is_static_right_open<typename interval_type_of<Type>::type>
+ , boost::detail::is_incrementable<typename domain_type_of<Type>::type>
+ >
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename domain_type_of<Type>::type& key_val)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::interval_type interval_type;
+ const_iterator first_collision = object.lower_bound(icl::detail::unit_trail<interval_type>(key_val));
+ // A part of the unit_trail(key_value)-interval may be found in the container, that
+ // does not contain key_value. Therefore we have to check for its existence:
+ return ( first_collision == object.end()
+ || icl::contains(key_value<Type>(first_collision), key_val) )
+ ? first_collision
+ : object.end();
+}
+
+template<class Type> inline
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_continuous<typename domain_type_of<Type>::type>
+ , is_static_left_open<typename interval_type_of<Type>::type>
+ , boost::detail::is_incrementable<typename domain_type_of<Type>::type>
+ >
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename domain_type_of<Type>::type& key_val)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::interval_type interval_type;
+ const_iterator last_collision = object.upper_bound(icl::detail::unit_trail<interval_type>(key_val));
+ if(last_collision != object.begin())
+ --last_collision;
+ // A part of the unit_trail(key_value)-interval may be found in the container, that
+ // does not contain key_value. Therefore we have to check for its existence:
+ return ( last_collision == object.end()
+ || icl::contains(key_value<Type>(last_collision), key_val) )
+ ? last_collision
+ : object.end();
+}
+
+// NOTE: find(object, key) won't compile if key is of continuous type that does
+// not implement in(de)crementation (e.g. std::string).
+
+template<class Type> inline
+typename enable_if< is_interval_container<Type>
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename interval_type_of<Type>::type& inter_val)
+{
+ return object.find(inter_val);
+}
+
+//==============================================================================
+//= Morphisms
+//==============================================================================
+template<class Type>
+typename enable_if<is_interval_container<Type>, Type>::type&
+join(Type& object)
+{
+ typedef typename Type::interval_type interval_type;
+ typedef typename Type::iterator iterator;
+
+ iterator it_ = object.begin();
+ if(it_ == object.end())
+ return object;
+
+ iterator next_ = it_; next_++;
+
+ while(next_ != object.end())
+ {
+ if( segmental::is_joinable<Type>(it_, next_) )
+ {
+ iterator fst_mem = it_; // hold the first member
+
+ // Go on while touching members are found
+ it_++; next_++;
+ while( next_ != object.end()
+ && segmental::is_joinable<Type>(it_, next_) )
+ { it_++; next_++; }
+
+ // finally we arrive at the end of a sequence of joinable intervals
+ // and it points to the last member of that sequence
+ const_cast<interval_type&>(key_value<Type>(it_))
+ = hull(key_value<Type>(it_), key_value<Type>(fst_mem));
+ object.erase(fst_mem, it_);
+
+ it_++; next_=it_;
+ if(next_!=object.end())
+ next_++;
+ }
+ else { it_++; next_++; }
+ }
+ return object;
+}
+
+}} // namespace boost icl
+
+#endif
+
+

Modified: sandbox/icl/boost/icl/concept/interval_map.hpp
==============================================================================
--- sandbox/icl/boost/icl/concept/interval_map.hpp (original)
+++ sandbox/icl/boost/icl/concept/interval_map.hpp 2011-03-13 16:24:00 EDT (Sun, 13 Mar 2011)
@@ -102,7 +102,7 @@
             , bool>::type
 contains(const Type& super, const typename Type::domain_type& key)
 {
- return super.find(key) != super.end();
+ return icl::find(super, key) != super.end();
 }
 
 template<class Type>
@@ -372,7 +372,7 @@
     typedef typename Type::segment_type segment_type;
     typedef typename Type::const_iterator const_iterator;
 
- const_iterator it_ = object.find(key_value);
+ const_iterator it_ = icl::find(object, key_value);
     if(it_ != object.end())
         add(section, segment_type(interval_type(key_value),it_->second));
 }


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