Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56177 - in sandbox/itl: boost/itl boost/itl/detail boost/itl/type_traits libs/itl/test libs/itl/test/test_casual_ libs/itl/test/test_separate_interval_set_
From: afojgo_at_[hidden]
Date: 2009-09-14 03:26:20


Author: jofaber
Date: 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
New Revision: 56177
URL: http://svn.boost.org/trac/boost/changeset/56177

Log:
Added concept checks. Stable {msvc-9.0r+d; inspected}

Added:
   sandbox/itl/boost/itl/detail/concept_check.hpp (contents, props changed)
Text files modified:
   sandbox/itl/boost/itl/interval.hpp | 29 ++++++++++++++++++++---------
   sandbox/itl/boost/itl/interval_base_map.hpp | 16 ++++++++++++++--
   sandbox/itl/boost/itl/map.hpp | 28 +++++++++++++++++++++++-----
   sandbox/itl/boost/itl/set.hpp | 25 +++++++++++++++++++------
   sandbox/itl/boost/itl/type_traits/is_continuous.hpp | 8 ++++++++
   sandbox/itl/boost/itl/type_traits/unon.hpp | 2 ++
   sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp | 1 -
   sandbox/itl/libs/itl/test/test_interval_map_shared.hpp | 1 +
   sandbox/itl/libs/itl/test/test_separate_interval_set_/vc9_test_separate_interval_set.vcproj | 4 ++++
   sandbox/itl/libs/itl/test/test_type_lists.hpp | 8 ++++----
   10 files changed, 95 insertions(+), 27 deletions(-)

Added: sandbox/itl/boost/itl/detail/concept_check.hpp
==============================================================================
--- (empty file)
+++ sandbox/itl/boost/itl/detail/concept_check.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -0,0 +1,31 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2009-2009: 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_ITL_CONCEPT_CHECK_HPP_JOFA_090913
+#define BOOST_ITL_CONCEPT_CHECK_HPP_JOFA_090913
+
+#include <boost/concept_check.hpp>
+#include <boost/concept/detail/concept_def.hpp>
+
+namespace boost{ namespace itl
+{
+
+ BOOST_concept(EqualComparable,(Type))
+ {
+ BOOST_CONCEPT_USAGE(EqualComparable) {
+ require_boolean_expr(_left == _right);
+ }
+ private:
+ Type _left, _right;
+ };
+
+}}// namespace boost itl
+
+
+#endif
+
+

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -15,6 +15,7 @@
 #include <string>
 #include <boost/assert.hpp>
 #include <boost/static_assert.hpp>
+#include <boost/concept_check.hpp>
 #include <boost/next_prior.hpp>
 #include <boost/call_traits.hpp>
 #include <boost/mpl/bool.hpp>
@@ -30,8 +31,6 @@
 #include <boost/itl/type_traits/value_size.hpp>
 #include <boost/itl/type_traits/to_string.hpp>
 
-#define BOUND_VALUE first
-#define BOUND_TYPES second
 
 namespace boost{namespace itl
 {
@@ -97,17 +96,29 @@
     //==========================================================================
     /** Default constructor; yields an empty interval <tt>[1,0]</tt> */
     interval() : _lwb(unon<DomainT>::value()), _upb(neutron<DomainT>::value()),
- _boundtype(itl::closed_bounded) {}
+ _boundtype(itl::closed_bounded)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ }
 
     //NOTE: Compiler generated copy constructor is used
 
     /** Constructor for a closed singleton interval <tt>[val,val]</tt> */
     explicit interval(const DomainT& val) :
- _lwb(val), _upb(val), _boundtype(itl::closed_bounded) {}
+ _lwb(val), _upb(val), _boundtype(itl::closed_bounded)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ }
 
     /** Interval from <tt>low</tt> to <tt>up</tt> with bounds <tt>bounds</tt> */
     interval(const DomainT& low, const DomainT& up, itl::bound_type bounds = itl::closed_bounded) :
- _lwb(low), _upb(up), _boundtype(bounds) {}
+ _lwb(low), _upb(up), _boundtype(bounds)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ }
 
     /** Closed interval <tt>[low,up]</tt> */
     static interval closed(const DomainT& low, const DomainT& up)
@@ -387,8 +398,8 @@
 
     bound_type succession_bounds()const;
 
- void set_lwb(const BoundT& lw) { _lwb=lw.BOUND_VALUE; set_lwb_type(lw.BOUND_TYPES); }
- void set_upb(const BoundT& up) { _upb=up.BOUND_VALUE; set_upb_type(up.BOUND_TYPES); }
+ void set_lwb(const BoundT& lw) { _lwb=lw.first; set_lwb_type(lw.second); }
+ void set_upb(const BoundT& up) { _upb=up.first; set_upb_type(up.second); }
 
     BoundT lwb_min(const interval& x2)const;
     BoundT lwb_max(const interval& x2)const;
@@ -883,14 +894,14 @@
 template <class DomainT, ITL_COMPARE Compare>
 inline DomainT interval<DomainT,Compare>::first()const
 {
- BOOST_ASSERT((!itl::is_continuous<DomainT>::value));
+ BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
     return is_left(closed_bounded) ? _lwb : succ(_lwb);
 }
 
 template <class DomainT, ITL_COMPARE Compare>
 inline DomainT interval<DomainT,Compare>::last()const
 {
- BOOST_ASSERT((!itl::is_continuous<DomainT>::value));
+ BOOST_STATIC_ASSERT((!itl::is_continuous<DomainT>::value));
     return is_right(closed_bounded) ? _upb : pred(_upb);
 }
 

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 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -164,10 +164,22 @@
     //= Construct, copy, destruct
     //==========================================================================
     /** Default constructor for the empty object */
- interval_base_map(){}
+ interval_base_map()
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<CodomainT>));
+ BOOST_CONCEPT_ASSERT((EqualComparableConcept<CodomainT>));
+ }
 
     /** Copy constructor */
- interval_base_map(const interval_base_map& src): _map(src._map) {}
+ interval_base_map(const interval_base_map& src): _map(src._map)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<CodomainT>));
+ BOOST_CONCEPT_ASSERT((EqualComparableConcept<CodomainT>));
+ }
 
     /** Assignment operator */
     interval_base_map& operator = (const interval_base_map& src)

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -11,6 +11,7 @@
 #include <string>
 #include <boost/itl/detail/notate.hpp>
 #include <boost/itl/detail/design_config.hpp>
+#include <boost/itl/detail/concept_check.hpp>
 #include <boost/itl/type_traits/is_map.hpp>
 #include <boost/itl/type_traits/has_inverse.hpp>
 #include <boost/itl/type_traits/to_string.hpp>
@@ -121,18 +122,35 @@
     //==========================================================================
     //= Construct, copy, destruct
     //==========================================================================
- map(){}
+ map()
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<CodomainT>));
+ BOOST_CONCEPT_ASSERT((EqualComparableConcept<CodomainT>));
+ }
+
     map(const key_compare& comp): base_type(comp){}
 
     template <class InputIterator>
- map(InputIterator first, InputIterator past): base_type(first,past) {}
+ map(InputIterator first, InputIterator past): base_type(first,past){}
 
     template <class InputIterator>
- map(InputIterator first, InputIterator past, const key_compare& comp): base_type(first,past,comp) {}
+ map(InputIterator first, InputIterator past, const key_compare& comp): base_type(first,past,comp)
+ {}
 
- map(const map& src): base_type::map(src){}
+ map(const map& src): base_type::map(src)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<CodomainT>));
+ BOOST_CONCEPT_ASSERT((EqualComparableConcept<CodomainT>));
+ }
 
- explicit map(const element_type& key_value_pair): base_type::map(){ insert(key_value_pair); }
+ explicit map(const element_type& key_value_pair): base_type::map()
+ {
+ insert(key_value_pair);
+ }
 
     map& operator=(const map& src) { base_type::operator=(src); return *this; }
     void swap(map& src) { base_type::swap(src); }

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -10,6 +10,7 @@
 
 #include <string>
 #include <set>
+#include <boost/itl/detail/concept_check.hpp>
 #include <boost/itl/type_traits/to_string.hpp>
 #include <boost/itl/type_traits/is_set.hpp>
 #include <boost/itl/type_traits/is_interval_container.hpp>
@@ -74,21 +75,33 @@
     //==========================================================================
     //= Construct, copy, destruct
     //==========================================================================
- set(){}
+ set()
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ }
+
     explicit set(const domain_compare& comp):
- std::set<DomainT, domain_compare, Alloc<DomainT> >(comp){}
+ std::set<DomainT, domain_compare, Alloc<DomainT> >(comp){}
 
     template <class InputIterator>
     set(InputIterator first, InputIterator past):
- std::set<InputIterator>(first,past) {}
+ std::set<InputIterator>(first,past){}
 
     template <class InputIterator>
     set(InputIterator first, InputIterator past, const key_compare& comp):
- std::set<InputIterator>(first, past, comp) {}
+ std::set<InputIterator>(first, past, comp){}
 
- set(const set& src): base_type::set(src){}
+ set(const set& src): base_type::set(src)
+ {
+ BOOST_CONCEPT_ASSERT((DefaultConstructibleConcept<DomainT>));
+ BOOST_CONCEPT_ASSERT((LessThanComparableConcept<DomainT>));
+ }
 
- explicit set(const element_type& key): base_type::set(){ insert(key); }
+ explicit set(const element_type& key): base_type::set()
+ {
+ insert(key);
+ }
 
     set& operator=(const set& src) { base_type::operator=(src); return *this; }
     void swap(set& src) { base_type::swap(src); }

Modified: sandbox/itl/boost/itl/type_traits/is_continuous.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_continuous.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_continuous.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -20,11 +20,19 @@
         typedef is_continuous<float> type;
         BOOST_STATIC_CONSTANT(bool, value = true);
     };
+
     template<> struct is_continuous<double>
     {
         typedef is_continuous<double> type;
         BOOST_STATIC_CONSTANT(bool, value = true);
     };
+
+ template<> struct is_continuous<long double>
+ {
+ typedef is_continuous<long double> type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+
     template<> struct is_continuous<std::string>
     {
         typedef is_continuous<std::string> type;

Modified: sandbox/itl/boost/itl/type_traits/unon.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/unon.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/unon.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -18,6 +18,8 @@
 
     template<> inline float unon<float>::value() { return 1.0; }
     template<> inline double unon<double>::value() { return 1.0; }
+ template<> inline long double unon<long double>::value()
+ { return 1.0; }
     
     // Smallest 'visible' string that is greater than the empty string.
     template <>

Modified: sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp (original)
+++ sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -91,5 +91,4 @@
 
     inclusion_compare(eleset_a, eleset_c);
     BOOST_CHECK_EQUAL(inclusion_compare(eleset_a, eleset_c), inclusion::unrelated);
-
 }

Modified: sandbox/itl/libs/itl/test/test_interval_map_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map_shared.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -337,6 +337,7 @@
 
     BOOST_CHECK_EQUAL( is_1_3_5.cardinality(), s3 );
     BOOST_CHECK_EQUAL( is_1_3_5.size(), s3 );
+ is_1_3_5.length();
     BOOST_CHECK_EQUAL( is_1_3_5.length(), d0 );
     BOOST_CHECK_EQUAL( is_1_3_5.interval_count(), 3 );
     BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(), 3 );

Modified: sandbox/itl/libs/itl/test/test_separate_interval_set_/vc9_test_separate_interval_set.vcproj
==============================================================================
--- sandbox/itl/libs/itl/test/test_separate_interval_set_/vc9_test_separate_interval_set.vcproj (original)
+++ sandbox/itl/libs/itl/test/test_separate_interval_set_/vc9_test_separate_interval_set.vcproj 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -208,6 +208,10 @@
                         UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
                 </Filter>
+ <File
+ RelativePath=".\ClassDiagram1.cd"
+ >
+ </File>
         </Files>
         <Globals>
         </Globals>

Modified: sandbox/itl/libs/itl/test/test_type_lists.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_type_lists.hpp (original)
+++ sandbox/itl/libs/itl/test/test_type_lists.hpp 2009-09-14 03:26:18 EDT (Mon, 14 Sep 2009)
@@ -26,7 +26,7 @@
 typedef ::boost::mpl::list<
     unsigned short, unsigned int, unsigned long
     ,short, int, long
- ,float, double
+ ,float, double, long double
     ,boost::rational<int>
     ,boost_posix_time_ptime
 // ,boost::gregorian::date
@@ -47,7 +47,7 @@
> debug_types;
 
 typedef ::boost::mpl::list<
- float, double
+ float, double, long double
     ,boost::rational<int>
> bicremental_continuous_types;
 
@@ -80,7 +80,7 @@
 typedef unsigned int discrete_type_5;
 
 typedef ::boost::mpl::list<
- float, double
+ float, double, long double
     ,boost::rational<int>
     ,std::string
> continuous_types;
@@ -93,7 +93,7 @@
 typedef ::boost::mpl::list<
     unsigned short, unsigned int, unsigned long
     ,short, int, long
- ,float, double
+ ,float, double, long double
     ,boost::rational<int>
     ,std::string
     ,boost_posix_time_ptime


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