|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66133 - in sandbox/itl: boost/itl boost/itl/type_traits libs/itl/example/interval_ libs/itl/test libs/itl/test/fastest_set_itl_set_ libs/itl/test/test_casual_
From: afojgo_at_[hidden]
Date: 2010-10-21 10:34:57
Author: jofaber
Date: 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
New Revision: 66133
URL: http://svn.boost.org/trac/boost/changeset/66133
Log:
Modified example interval. Added statically bounded intervals. Modified meta code for sets. Tested for interprocess/set. Stable{msvc-9.0,10.0, gcc-3.4.4}
Text files modified:
sandbox/itl/boost/itl/rational.hpp | 2 +
sandbox/itl/boost/itl/type_traits/codomain_type_of.hpp | 31 ++++++++++++++++++--------
sandbox/itl/boost/itl/type_traits/is_set.hpp | 3 +
sandbox/itl/libs/itl/example/interval_/interval.cpp | 45 ++++++++++++++++++++++++++++++++++++---
sandbox/itl/libs/itl/test/fastest_set_itl_set_/fastest_set_itl_set.cpp | 1
sandbox/itl/libs/itl/test/test_casual_/test_casual.cpp | 13 +++++++----
sandbox/itl/libs/itl/test/test_set_itl_set.hpp | 15 ++++++++----
7 files changed, 85 insertions(+), 25 deletions(-)
Modified: sandbox/itl/boost/itl/rational.hpp
==============================================================================
--- sandbox/itl/boost/itl/rational.hpp (original)
+++ sandbox/itl/boost/itl/rational.hpp 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -13,6 +13,8 @@
#ifndef BOOST_ICL_RATIONAL_HPP_JOFA_080913
#define BOOST_ICL_RATIONAL_HPP_JOFA_080913
+#include <boost/config.hpp> // For BOOST_MSVC and more
+
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4127) // conditional expression is constant
Modified: sandbox/itl/boost/itl/type_traits/codomain_type_of.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/codomain_type_of.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/codomain_type_of.hpp 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -12,6 +12,7 @@
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/itl/type_traits/no_type.hpp>
+#include <boost/itl/type_traits/is_container.hpp>
namespace boost{ namespace icl
{
@@ -25,34 +26,44 @@
: mpl::bool_<detail::has_codomain_type<Type>::value>
{};
- template <class Type, bool has_codomain_type>
+ template <class Type, bool has_codomain_type, bool is_std_set>
struct get_codomain_type;
template <class Type>
- struct get_codomain_type<Type, false>
+ struct get_codomain_type<Type, false, false>
{
typedef no_type type;
};
- template <class Type>
- struct get_codomain_type<Type, true>
+ template <class Type, bool is_std_set>
+ struct get_codomain_type<Type, true, is_std_set>
{
typedef typename Type::codomain_type type;
};
template <class Type>
- struct codomain_type_of
+ struct get_codomain_type<Type, false, true>
{
- typedef typename
- get_codomain_type<Type, has_codomain_type<Type>::value>::type type;
+ typedef typename Type::value_type type;
};
- template <class DomainT, class Compare, class Alloc>
- struct codomain_type_of<std::set<DomainT,Compare,Alloc> >
+ template <class Type>
+ struct codomain_type_of
{
- typedef typename std::set<DomainT,Compare,Alloc>::value_type type;
+ typedef typename
+ get_codomain_type< Type
+ , has_codomain_type<Type>::value
+ , is_std_set<Type>::value
+ >::type type;
};
+ //CL
+ //template <class DomainT, class Compare, class Alloc>
+ //struct codomain_type_of<std::set<DomainT,Compare,Alloc> >
+ //{
+ // typedef typename std::set<DomainT,Compare,Alloc>::value_type type;
+ //};
+
}} // namespace boost icl
#endif
Modified: sandbox/itl/boost/itl/type_traits/is_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/type_traits/is_set.hpp (original)
+++ sandbox/itl/boost/itl/type_traits/is_set.hpp 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -9,13 +9,14 @@
#define BOOST_ICL_TYPE_TRAITS_IS_SET_HPP_JOFA_081004
#include <boost/config.hpp>
+#include <boost/itl/type_traits/is_container.hpp>
namespace boost{ namespace icl
{
template <class Type> struct is_set
{
typedef is_set<Type> type;
- BOOST_STATIC_CONSTANT(bool, value = false);
+ BOOST_STATIC_CONSTANT(bool, value = is_std_set<Type>::value);
};
}} // namespace boost icl
Modified: sandbox/itl/libs/itl/example/interval_/interval.cpp
==============================================================================
--- sandbox/itl/libs/itl/example/interval_/interval.cpp (original)
+++ sandbox/itl/libs/itl/example/interval_/interval.cpp 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------------+
Interval Container Library
Author: Joachim Faulhaber
-Copyright (c) 2007-2009: Joachim Faulhaber
+Copyright (c) 2007-2010: Joachim Faulhaber
Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
+------------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
@@ -13,8 +13,8 @@
Closed and open interval borders.
Much of the library code deals with intervals which are implemented
- as class interval. This program gives a very short samlpe of different
- interval instances.
+ by interval class templates. This program gives a very short samlpe of
+ different interval instances.
\include interval_/interval.cpp
*/
@@ -22,11 +22,22 @@
#include <iostream>
#include <string>
#include <math.h>
+
+// Dynamically bounded intervals
#include <boost/itl/discrete_interval.hpp>
#include <boost/itl/continuous_interval.hpp>
+
+// Statically bounded intervals
+#include <boost/itl/right_open_interval.hpp>
+#include <boost/itl/left_open_interval.hpp>
+#include <boost/itl/closed_interval.hpp>
+#include <boost/itl/open_interval.hpp>
+
#include "../toytime.hpp"
+#include <boost/itl/rational.hpp>
using namespace std;
+using namespace boost;
using namespace boost::icl;
int main()
@@ -34,8 +45,14 @@
cout << ">>Interval Container Library: Sample interval.cpp <<\n";
cout << "----------------------------------------------------\n";
+ // Class template discrete_interval can be used for discrete data types
+ // like integers, date and time and other types that have a least steppable
+ // unit.
discrete_interval<int> int_interval
= construct<discrete_interval<int> >(3, 7, interval_bounds::closed());
+
+ // Class template continuous_interval can be used for continuous data types
+ // like double, boost::rational or strings.
continuous_interval<double> sqrt_interval
= construct<continuous_interval<double> >(1/sqrt(2.0), sqrt(2.0));
//interval_bounds::right_open() is default
@@ -46,6 +63,7 @@
= construct<discrete_interval<Time> >(Time(monday,8,30), Time(monday,17,20),
interval_bounds::open());
+ cout << "Dynamically bounded interval\n";
cout << " discrete_interval<int>: " << int_interval << endl;
cout << "continuous_interval<double>: " << sqrt_interval << " does "
<< string(contains(sqrt_interval, sqrt(2.0))?"":"NOT")
@@ -56,7 +74,21 @@
cout << "continuous_interval<string>: " << city_interval << " does "
<< string(contains(city_interval, "Berlin")?"":"NOT")
<< " contain 'Berlin'" << endl;
- cout << " discrete_interval<Time>: " << time_interval << endl;
+ cout << " discrete_interval<Time>: " << time_interval << "\n\n";
+
+ // There are statically bounded interval types with fixed interval borders
+ right_open_interval<string> fix_interval1; // You will probably use one kind of static intervals
+ // right_open_intervals are recommended.
+ closed_interval<unsigned int> fix_interval2; // ... static closed, left_open and open intervals
+ left_open_interval<float> fix_interval3; // are implemented for sake of completeness but
+ open_interval<short> fix_interval4; // are of minor practical importance.
+
+ right_open_interval<rational<int> > range1(rational<int>(0,1), rational<int>(2,3));
+ right_open_interval<rational<int> > range2(rational<int>(1,3), rational<int>(1,1));
+
+ // This middle third of the unit interval [0,1)
+ cout << "Statically bounded interval\n";
+ cout << "right_open_interval<rational<int>>: " << (range1 & range2) << endl;
return 0;
}
@@ -65,10 +97,15 @@
//>>Interval Container Library: Sample interval.cpp <<
//----------------------------------------------------
+//Dynamically bounded interval
// discrete_interval<int>: [3,7]
//continuous_interval<double>: [0.707107,1.41421) does NOT contain sqrt(2)
//continuous_interval<string>: (Barcelona,Boston] does NOT contain 'Barcelona'
//continuous_interval<string>: (Barcelona,Boston] does contain 'Berlin'
// discrete_interval<Time>: (mon:08:30,mon:17:20)
+//
+//Statically bounded interval
+//right_open_interval<rational<int>>: [1/3,2/3)
+
//]
Modified: sandbox/itl/libs/itl/test/fastest_set_itl_set_/fastest_set_itl_set.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/fastest_set_itl_set_/fastest_set_itl_set.cpp (original)
+++ sandbox/itl/libs/itl/test/fastest_set_itl_set_/fastest_set_itl_set.cpp 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -19,6 +19,7 @@
//JODO include
//------------------------------------------------------------------------------
#include <set>
+#include <boost/interprocess/containers/set.hpp>
#include <boost/itl/concept/container.hpp>
#include <boost/itl/concept/element_set.hpp>
#include <boost/itl/concept/element_associator.hpp>
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 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -21,6 +21,7 @@
#include <boost/type_traits/is_const.hpp>
#include <boost/detail/is_incrementable.hpp>
#include <boost/type_traits/is_floating_point.hpp>
+#include <boost/interprocess/containers/set.hpp>
#define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
#define BOOST_ICL_DISCRETE_STATIC_INTERVAL_DEFAULT right_open_interval
@@ -315,12 +316,12 @@
BOOST_CHECK_EQUAL(has_codomain_type<MapII>::value, true);
BOOST_CHECK_EQUAL((is_same<MapII::codomain_type, int>::value), true);
- BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII,true>::type, int>::value), true);
- BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII,false>::type, int>::value), false);
- BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII,false>::type, icl::no_type>::value), true);
+ //BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII,true>::type, int>::value), true);
+ //BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII,false>::type, int>::value), false);
+ //BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII,false>::type, icl::no_type>::value), true);
- BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII, has_codomain_type<MapII>::value >::type, int>::value), true);
- BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII, has_codomain_type<MapII>::value >::type, icl::no_type>::value), false);
+ //BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII, has_codomain_type<MapII>::value >::type, int>::value), true);
+ //BOOST_CHECK_EQUAL((is_same<get_codomain_type<MapII, has_codomain_type<MapII>::value >::type, icl::no_type>::value), false);
BOOST_CHECK_EQUAL((is_map<MapII>::value), true);
BOOST_CHECK_EQUAL((is_icl_container<MapII>::value), true);
@@ -414,5 +415,7 @@
BOOST_CHECK_EQUAL( (is_const<std::set<int>::key_type >::value), false );
BOOST_CHECK_EQUAL( (is_const<std::set<int>::value_type >::value), false );
+ BOOST_CHECK_EQUAL( (is_std_set<interprocess::set<int> >::value), true );
+ BOOST_CHECK_EQUAL( (is_element_set<interprocess::set<int> >::value), true );
}
Modified: sandbox/itl/libs/itl/test/test_set_itl_set.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_set_itl_set.hpp (original)
+++ sandbox/itl/libs/itl/test/test_set_itl_set.hpp 2010-10-21 10:34:55 EDT (Thu, 21 Oct 2010)
@@ -23,7 +23,8 @@
{
typedef IntervalSet<T> IntervalSetT;
typedef typename IntervalSetT::interval_type IntervalT;
- typedef std::set<T> SetT;
+ //typedef std::set<T> SetT;
+ typedef interprocess::set<T> SetT;
IntervalSetT itv_set_a, itv_set_b, itv_set_c;
itv_set_a.add(I_D(3,6)).add(I_I(5,7));
@@ -53,7 +54,8 @@
{
typedef IntervalSet<T> IntervalSetT;
typedef typename IntervalSetT::interval_type IntervalT;
- typedef std::set<T> SetT;
+ //typedef std::set<T> SetT;
+ typedef interprocess::set<T> SetT;
IntervalSetT itv_set_a, itv_set_b, itv_set_c;
itv_set_a.add(I_D(3,6)).add(I_I(5,7));
@@ -87,7 +89,8 @@
{
typedef IntervalSet<T> IntervalSetT;
typedef typename IntervalSetT::interval_type IntervalT;
- typedef std::set<T> SetT;
+ //typedef std::set<T> SetT;
+ typedef interprocess::set<T> SetT;
IntervalSetT itv_set_a, itv_set_b, itv_set_c;
itv_set_a.add(I_D(3,6)).add(I_I(5,7));
@@ -117,7 +120,8 @@
{
typedef IntervalSet<T> IntervalSetT;
typedef typename IntervalSetT::interval_type IntervalT;
- typedef std::set<T> SetT;
+ //typedef std::set<T> SetT;
+ typedef interprocess::set<T> SetT;
IntervalSetT itv_set_a, itv_set_b, itv_set_c;
itv_set_a.add(I_D(3,6)).add(I_I(5,7));
@@ -151,7 +155,8 @@
{
typedef IntervalSet<T> IntervalSetT;
typedef typename IntervalSetT::interval_type IntervalT;
- typedef std::set<T> SetT;
+ //typedef std::set<T> SetT;
+ typedef interprocess::set<T> SetT;
IntervalSetT itv_set_a, itv_set_b, itv_set_c;
itv_set_a.add(I_D(3,6)).add(I_I(5,7));
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