|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50334 - in sandbox/itl: boost/itl libs/itl/doc libs/itl/test libs/itl_xt/test/meta_functors libs/validate/example/labatea
From: afojgo_at_[hidden]
Date: 2008-12-20 15:30:38
Author: jofaber
Date: 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
New Revision: 50334
URL: http://svn.boost.org/trac/boost/changeset/50334
Log:
Added documentation. Interface, requirements on template parameters (2). Stable {msvc-9.0, partly congcc-4.3-a7}
Text files modified:
sandbox/itl/boost/itl/functors.hpp | 58 +++++++++++---
sandbox/itl/boost/itl/interval_base_map.hpp | 1
sandbox/itl/boost/itl/interval_map.hpp | 31 ++++---
sandbox/itl/libs/itl/doc/interface.qbk | 159 +++++++++++++++++++++++++++++++--------
sandbox/itl/libs/itl/doc/itl.qbk | 1
sandbox/itl/libs/itl/test/test_type_lists.hpp | 4
sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp | 65 ++++++++++++++++
sandbox/itl/libs/validate/example/labatea/labatea.cpp | 12 +-
8 files changed, 258 insertions(+), 73 deletions(-)
Modified: sandbox/itl/boost/itl/functors.hpp
==============================================================================
--- sandbox/itl/boost/itl/functors.hpp (original)
+++ sandbox/itl/boost/itl/functors.hpp 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -34,10 +34,25 @@
namespace boost{namespace itl
{
// ------------------------------------------------------------------------
- template <typename Type> struct inplace_identity
+ template <typename Type> struct neutron_based_inplace_combine
: public std::binary_function<Type&, const Type&, void>
{
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
+ };
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct unon_based_inplace_combine
+ : public std::binary_function<Type&, const Type&, void>
+ {
+ static Type neutron() { return boost::itl::unon<Type>::value(); }
+ };
+
+ // ------------------------------------------------------------------------
+ template <typename Type> struct inplace_identity
+ : public neutron_based_inplace_combine<Type>
+ {
void operator()(Type& object, const Type& operand)const{}
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -46,13 +61,14 @@
// ------------------------------------------------------------------------
template <typename Type> struct inplace_erasure
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{
if(object == operand)
object = Type();
}
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -61,7 +77,7 @@
// ------------------------------------------------------------------------
template <typename Type> struct inplace_plus
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
typedef Type type;
@@ -74,11 +90,13 @@
// ------------------------------------------------------------------------
template <typename Type> struct inplace_minus
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
typedef Type type;
void operator()(Type& object, const Type& operand)const
{ object -= operand; }
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -86,10 +104,12 @@
// ------------------------------------------------------------------------
template <typename Type> struct inserter
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{ insert(object,operand); }
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -97,10 +117,12 @@
// ------------------------------------------------------------------------
template <typename Type> struct eraser
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{ erase(object,operand); }
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -108,35 +130,41 @@
// ------------------------------------------------------------------------
template <typename Type> struct inplace_star
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{ object *= operand; }
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
inline std::string unary_template_to_string<inplace_star>::apply() { return "*="; }
// ------------------------------------------------------------------------
- template <typename Type> struct inplace_div
- : public std::binary_function<Type&, const Type&, void>
+ template <typename Type> struct inplace_slash
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{ object /= operand; }
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
- inline std::string unary_template_to_string<inplace_div>::apply() { return "/="; }
+ inline std::string unary_template_to_string<inplace_slash>::apply() { return "/="; }
// ------------------------------------------------------------------------
template <typename Type> struct inplace_max
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{
if(object < operand)
object = operand;
}
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -144,13 +172,15 @@
// ------------------------------------------------------------------------
template <typename Type> struct inplace_min
- : public std::binary_function<Type&, const Type&, void>
+ : public neutron_based_inplace_combine<Type>
{
void operator()(Type& object, const Type& operand)const
{
if(object > operand)
object = operand;
}
+
+ static Type neutron() { return boost::itl::neutron<Type>::value(); }
};
template<>
@@ -170,10 +200,10 @@
template<class Type>
struct inverse<itl::inplace_star<Type> >
- { typedef itl::inplace_div<Type> type; };
+ { typedef itl::inplace_slash<Type> type; };
template<class Type>
- struct inverse<itl::inplace_div<Type> >
+ struct inverse<itl::inplace_slash<Type> >
{ typedef itl::inplace_star<Type> type; };
template<class Type>
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-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -143,6 +143,7 @@
template<class,ITL_COMPARE>class Interval = itl::interval,
ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, DomainT),
ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, CodomainT),
+ //ITL_SECTION Section= ITL_SECTION_INSTANCE(itl::inplace_et, CodomainT),
ITL_ALLOC Alloc = std::allocator
>
#ifdef USE_CONCEPTS
Modified: sandbox/itl/boost/itl/interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_map.hpp 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -203,7 +203,8 @@
bool insertable(const value_type& value)const
{
return !value.KEY_VALUE.empty()
- && !(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT());
+ && !(Traits::absorbs_neutrons && value.CONT_VALUE == codomain_combine::neutron());
+ //CL && !(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT());
}
bool join_left(iterator& it);
@@ -348,7 +349,7 @@
//collision free insert is asserted
if(value.KEY_VALUE.empty())
return this->_map.end();
- if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == codomain_combine::neutron())
return this->_map.end();
std::pair<iterator,bool> insertion = this->_map.insert(value);
@@ -367,7 +368,7 @@
//collision free insert is asserted
if(value.KEY_VALUE.empty())
return this->_map.end();
- if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == codomain_combine::neutron())
return this->_map.end();
std::pair<iterator,bool> insertion = this->_map.insert(value);
@@ -388,13 +389,13 @@
//collision free insert is asserted
if(value.KEY_VALUE.empty())
return this->_map.end();
- if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == Combiner::neutron())
return this->_map.end();
std::pair<iterator,bool> insertion;
if(Traits::emits_neutrons)
{
- CodomainT added_val = CodomainT();
+ CodomainT added_val = Combiner::neutron();
Combiner()(added_val, value.CONT_VALUE);
if(Traits::absorbs_neutrons && added_val == neutron<CodomainT>::value())
return this->_map.end();
@@ -419,13 +420,13 @@
//collision free insert is asserted
if(value.KEY_VALUE.empty())
return this->_map.end();
- if(Traits::absorbs_neutrons && value.CONT_VALUE == CodomainT())
+ if(Traits::absorbs_neutrons && value.CONT_VALUE == Combiner::neutron())
return this->_map.end();
std::pair<iterator,bool> insertion;
if(Traits::emits_neutrons)
{
- CodomainT added_val = CodomainT();
+ CodomainT added_val = Combiner::neutron();
Combiner()(added_val, value.CONT_VALUE);
if(Traits::absorbs_neutrons && added_val == neutron<CodomainT>::value())
return this->_map.end();
@@ -454,13 +455,13 @@
return;
const CodomainT& x_val = x.CONT_VALUE;
- if(Traits::absorbs_neutrons && x_val==CodomainT())
+ if(Traits::absorbs_neutrons && x_val==Combiner::neutron())
return;
std::pair<iterator,bool> insertion;
if(Traits::emits_neutrons)
{
- CodomainT added_val = CodomainT();
+ CodomainT added_val = Combiner::neutron();
Combiner()(added_val, x_val);
if(Traits::absorbs_neutrons && added_val == neutron<CodomainT>::value())
return;
@@ -562,7 +563,7 @@
Combiner()(it->CONT_VALUE, x_val);
fill_gap_join_left<Combiner>(value_type(left_gap, x_val)); //A posteriori
- if(Traits::absorbs_neutrons && it->CONT_VALUE == CodomainT())
+ if(Traits::absorbs_neutrons && it->CONT_VALUE == Combiner::neutron())
this->_map.erase(it++);
else
{
@@ -632,7 +633,7 @@
return;
const CodomainT& x_val = x.CONT_VALUE;
- if(Traits::absorbs_neutrons && x_val==CodomainT())
+ if(Traits::absorbs_neutrons && x_val==Combiner::neutron())
return;
iterator fst_it = this->_map.lower_bound(x_itv);
@@ -702,7 +703,7 @@
CodomainT& cur_val = (*it).CONT_VALUE ;
Combiner()(cur_val, x_val);
- if(Traits::absorbs_neutrons && cur_val==CodomainT())
+ if(Traits::absorbs_neutrons && cur_val==Combiner::neutron())
this->_map.erase(it++);
else
{
@@ -723,7 +724,7 @@
{
CodomainT& cur_val = (*it).CONT_VALUE ;
Combiner()(cur_val, x_val);
- if(Traits::absorbs_neutrons && cur_val==CodomainT())
+ if(Traits::absorbs_neutrons && cur_val==Combiner::neutron())
this->_map.erase(it);
else
{
@@ -771,7 +772,7 @@
return;
const CodomainT& x_val = x.CONT_VALUE;
- if(Traits::absorbs_neutrons && x_val==CodomainT())
+ if(Traits::absorbs_neutrons && x_val==codomain_combine::neutron())
return;
std::pair<typename ImplMapT::iterator,bool>
@@ -894,7 +895,7 @@
return;
const CodomainT& x_val = x.CONT_VALUE;
- if(Traits::absorbs_neutrons && x_val==CodomainT())
+ if(Traits::absorbs_neutrons && x_val==codomain_combine::neutron())
return;
iterator fst_it = this->_map.lower_bound(x_itv);
Modified: sandbox/itl/libs/itl/doc/interface.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/interface.qbk (original)
+++ sandbox/itl/libs/itl/doc/interface.qbk 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -134,40 +134,66 @@
[section Required Concepts]
There are uniform requirements for the template parameters
-across *itl's* class templates that are summarized in the
-table below.
+across *itl's* class templates. The template parameters can
+be grouped with respect to those requirements.
[table
-[[Kind] [Parameter] [requires] ]
-[[`typename`][`DomainT`] [`Regular<DomainT> && LessThanComparable<DomainT,Compare>`
- `&& (IsIncrementable<DomainT>||HasUnon<DomainT>)`] ]
-[[][] [`if(IsIntegral<DomainT>) IsIncrementable<DomainT> && IsDecrementable<DomainT>`] ]
-[[`typename`][`CodomainT`][`EqualityComparable<CodomainT>`
- `&& Addable<CodomainT,Combine>`
- `&& Subtractable<CodomainT,Inverse<Combine> >`] ]
-[[`template`][`Compare`] [`LessThanComparable<DomainT,Compare>`] ]
-[[`template`][`Combine`] [`Addable<CodomainT,Combine>`
- `&& Subtractable<CodomainT,Inverse<Combine> >`]]
+[[] [used in] [Kind] [Parameter] [Instance] [Description] ]
+[[Domain order] [`interval, Sets, Maps`][`typename`][`DomainT`] [] [For the type `DomainT` of key elements]]
+[[] [] [`template`] [`Compare`] [`Compare<DomainT>`] [there is an order `Compare`] ]
+[[Interval type] [`interval_sets/maps`][`template`] [`Interval`] [`Interval<DomainT,Compare>`] [the `Interval` parameter has to use the same element type and order ] ]
+[[Codomain aggregation][`Maps`] [`typename`] [`CodomainT`][] [For the type `CodomainT` of associated values]]
+[[] [] [`template`] [`Combine`] [`Combine<CodomainT>`] [there is a binary functor `Combine<CodomainT>()` to combine them ] ]
+[[] [] [] [] [`Inverse<Combine<CodomainT>>`][and implicity an `Inverse` functor to inversely combine them. ] ]
+[[Memory allocation] [`Sets, Maps`] [`template`] [`Alloc`] [`Alloc<`/various/`>`] [An allocator can be chosen for memory allocation.]]
]
-[h5 Requirements on DomainT]
+[/ table
+[[Kind] [Parameter] [Condition] [Requirement] ]
+[[`typename`][`DomainT`] [] [`Regular<DomainT> && LessThanComparable<DomainT,Compare>`
+ `&& (IsIncrementable<DomainT>||HasUnon<DomainT>)`] ]
+[[][] [`IsIntegral<DomainT>`] [`IsIncrementable<DomainT> && IsDecrementable<DomainT>`] ]
+[[`typename`][`CodomainT`][`Combine` and `Inverse<Combine>` unused] []]
+[[][] [only `Combine` used ] [`EqualityComparable<CodomainT> && Addable<CodomainT,Combine>`] ]
+[[][] [also `Inverse<Combine>` used][`&& Subtractable<CodomainT,Inverse<Combine> >`] ]
+[[`template`][`Compare`] [] [`LessThanComparable<DomainT,Compare>`] ]
+[[`template`][`Combine`] [only `Combine` used] [`Addable<CodomainT,Combine>`]]
+[[][] [also `Inverse<Combine>` used][`&& Subtractable<CodomainT,Inverse<Combine> >`] ]
+]
+
+[h4 Requirements on DomainT]
-A domain type `DomainT` for intervals and interval conainer
-has to satisfy the requirements of concept `Regular` which
+The next table gives an overview over the requirements for
+template parameter `DomainT`. Some requirements are dependent
+on /conditions/. Column /operators/ shows the operators and
+functions that are expected for `DomainT`, if the default order
+`Compare = std::less` is used.
+
+[table
+[[Parameter] [Condition] [Operators] [Requirement] ]
+[[`DomainT`] [] [`DomainT(), <`] [`Regular<DomainT> && StrictWeakOrdering<DomainT,Compare>`]]
+[[] [] [`++, unon<CodomainT>::value()`][`&& (IsIncrementable<DomainT>||HasUnon<DomainT>)`] ]
+[[] [`IsIntegral<DomainT>`][`++, --`] [`IsIncrementable<DomainT> && IsDecrementable<DomainT>`] ]
+]
+
+A domain type `DomainT` for intervals and interval conainers
+has to satisfy the requirements of concept
+[@http://www.generic-programming.org/languages/conceptcpp/issues/concepts-closed.html `Regular`]
+which
implies among other properties the existence of a copy and
a default constructor. In addition `IsIncrementable`
*or* `HasUnon` is required for `DomainT`.
-
In the *itl* we represent an empty interval by a closed
-interval `[b,a]` where `a < b` (here `<` is represents `Compare<DomainT>()`).
+interval `[b,a]` where `a < b` (here `<` represents `Compare<DomainT>()`).
To construct one of these empty intervals as default constructor
for any type `DomainT` we choose `[1,0]`, where `0` is a null-value or `neutron`
and `1` is a one-value or `unon`:
``
-interval() := [unon<DomainT>::value(), neutron<DomainT>::value()]
+interval() := [unon<DomainT>::value(), neutron<DomainT>::value()] //pseudocode
``
`Neutrons` are implemented via call of the default constructor of
-`DomainT`. An `unon<T>::value()` is implemented by default as a `neutron`,
+`DomainT`. An `unon<T>::value()` is implemented
+[classref boost::itl::unon by default] as a `neutron`,
that is incremented once.
``
template <class Type>
@@ -175,37 +201,100 @@
``
So a type `DomainT` that is `incrementable` will
also have an `unon`. If it does not, an `unon` can be provided.
-An `unon` can be any value, that is greater as the neutron value
-in the Compare order given.
-
-An example of a type, that has a neutron but no increment is
-string. So for std::string an unon is implemented like this:
+An `unon` can be any value, that is greater as the `neutron` value
+in the `Compare` order given.
+An example of a type, that has a `neutron` but no increment is
+`string`. So for `std::string` an unon is implemented like this:
``
// Smallest 'visible' string that is greater than the empty string.
template <>
inline std::string unon<std::string>::value(){ return std::string(" "); };
``
-Just as the `_Key` type of std::sets and maps
-`DomainT` is required to be
-`LessThanComparable<DomainT,Compare>` wich means, that
-`Compare` has to be a
+Just as for the key type of std::sets and maps
+template parameter `Compare` is required to be a
[@http://en.wikipedia.org/wiki/Strict_weak_ordering strict weak ordering] on `DomainT`.
Finally, if `DomainT` is an integral type, `DomainT` needs to
-be `incrementable` and `decrementable`. This in(de)crementability
+be `incrementable` and `decrementable`. This [''bicrementability']
needs to be implemented on the smallest possible unit of the
integral type. This seems like being trivial but there are types like e.g.
`boost::date_time::ptime`, that are integral in nature but do
-not provide the required in(de)cementation.
-
+not provide the required in- and decrementation on the least incrementable unit.
For __itl_itvs__ incementation and decementation is used
-for moving open to closed interval borders like e.g.
-`[2,43) == [2,42]`. Such operations always need only
-one in(de)crementation, if `DomainT` is an integral type.
+for computations between open to closed interval borders like e.g.
+`[2,43) == [2,42]`. Such computations always need only
+one in- or decrementation, if `DomainT` is an integral type.
+
+[h4 Requirements on CodomainT]
+
+Summarized in the next table are requirements for template parameter
+`CodomainT` of associated values for `Maps`. Again there are
+/conditions/ for some of the requirements. Column /operators/
+contains the operators and functions required for `CodomainT`, if we are
+using the default combiner `Combine = itl::inplace_plus`.
-[h5 Requirements on CodomainT]
+[table
+[[Parameter] [Condition] [Operators] [Requirement] ]
+[[`CodomainT`][`add` and `subtract` unused][`CodomainT(), ==`][`Regular<CodomainT>` which implies] ]
+[[] [] [] [`DefaultConstructible<CodomainT> && EqualityComparable<CodomainT>`] ]
+[[] [only `add` used ] [`+=`] [`&& Combinable<CodomainT,Combine>`] ]
+[[] [also `subtract` used] [`-=`] [`&& Combinable<CodomainT,Inverse<Combine> >`]]
+]
+
+The requirements on the type `CodomainT` of associated values for a __itl_map__ or __itv_map__
+depend on the usage of their aggregation functionality. If aggregation on overlap
+is never used, that is to say neither `+, +=, add` nor `-, -=, subtract` are used on the
+__itv_map__, then `CodomainT` only needs to be `Regular`.
+Concept
+[@http://www.generic-programming.org/languages/conceptcpp/issues/concepts-closed.html `Regular` is under construction]
+but it can be said that it expresses the properties of common ['*regular*]
+object semantics that particularly implies `DefaultConstructible` and
+`EqualityComparable` which means it has
+a default ctor `CodomainT()` and an `operator ==`.
+
+Use __itv_maps__ ['*without aggregation*], if the associated values are not
+addable but still
+are attached to intervals so you want to use __itv_maps__ to handle them.
+As long as those values are added with `insert` and deleted with `erase`
+__itv_maps__ will work fine with such values.
+
+If ['*only addition*] is used via __itv_map_s__ `+, +=` or `add` but no subtraction,
+then `CodomainT` need to be `Combinable` for functor template `Combine`. That
+means in most cases when the default implementation `inplace_plus` for
+`Combine` is used, that `CodomainT` has to implement `operator +=`.
+
+For associated value types, that are addable but not subtractable like
+e.g. `std::string` it usually makes sense to use addition to combine values
+but the inverse combination is not desired.
+``
+interval_map<int,std::string> cat_map;
+cat_map += make_pair(interval<int>::rightopen(1,5),std::string("Hello"));
+cat_map += make_pair(interval<int>::rightopen(3,7),std::string(" world"));
+cout << "cat_map: " << cat_map << endl;
+//cat_map: {([1,3)->Hello)([3,5)->Hello world)([5,7)-> world)}
+``
+For ['complete aggregation functionality] and inverse aggregation functor on
+a `Map`'s `CodomainT` is needed. The itl provides a
+metafunction [classref boost::itl::inverse inverse]
+for that purpose. Using the default
+`Combine = inplace_plus` that relies on the existence of `operator +=`
+on type `CodomainT`
+metafunction [classref boost::itl::inverse inverse]
+will infer [classref boost::itl::inplace_minus inplace_minus]
+as inverse functor, that requries `operator -=` on type `CodomainT`.
+
+The `CodomainT` parameter of Itl's `Maps` is designed under the
+assumption that for a `Combiner` functor particularly for the
+default functor
+[classref boost::itl::inplace_minus inplace_plus] are
+
+In the itl's design we make the assumption,
+in particular for the default setting of parameters
+`Combine = `[classref boost::itl::inplace_minus inplace_plus],
+type `CodomainT` has a neutral element or `neutron`
+with respect to the `Combine` functor. This `neutron`
[endsect][/ Required Concepts]
Modified: sandbox/itl/libs/itl/doc/itl.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/itl.qbk (original)
+++ sandbox/itl/libs/itl/doc/itl.qbk 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -21,6 +21,7 @@
[def __itv__ [classref boost::itl::interval interval]]
[def __Itv__ [classref boost::itl::interval Interval]]
[def __itvs__ [classref boost::itl::interval intervals]]
+[def __itl_itvs__ [classref boost::itl::interval itl::intervals]]
[def __Itvs__ [classref boost::itl::interval Intervals]]
[def __itv_set__ [classref boost::itl::interval_set interval_set]]
[def __itv_sets__ [classref boost::itl::interval_set interval_sets]]
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 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -23,7 +23,7 @@
,short, int, long
,float, double
,boost::rational<int>
-// ,boost::posix_time::ptime
+ ,boost::posix_time::ptime
// ,boost::gregorian::date
> bicremental_types;
@@ -45,7 +45,7 @@
typedef ::boost::mpl::list<
unsigned short, unsigned int, unsigned long
,short, int, long
-// ,boost::posix_time::ptime
+ ,boost::posix_time::ptime
// ,boost::gregorian::date
> discrete_types;
Modified: sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp
==============================================================================
--- sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp (original)
+++ sandbox/itl/libs/itl_xt/test/meta_functors/meta_functors.cpp 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -33,9 +33,13 @@
#include <boost/mpl/apply.hpp>
#include <boost/mpl/placeholders.hpp>
+#include <boost/itl/interval_map.hpp>
+#include <boost/itl/split_interval_map.hpp>
+
using namespace std;
using namespace boost;
using namespace boost::mpl::placeholders;
+using namespace boost::itl;
template<class T>struct unary{
void speak(){ cout<<"unary"<<endl; }
@@ -162,11 +166,68 @@
}
*/
+class NoPlus
+{
+ //NoPlus(const NoPlus& val):_value(val._value){}
+public:
+ NoPlus():_value(0){}
+ NoPlus(int value):_value(value){}
+
+ bool operator < (const NoPlus& rhs)const
+ { return _value < rhs._value; }
+
+ bool operator == (const NoPlus& rhs)const
+ { return _value == rhs._value; }
+
+ int value()const { return _value; }
+
+ std::string as_string()const
+ { return to_string<int>::apply(_value); }
+
+private:
+ int _value;
+};
+
+template<class CharType, class CharTraits>
+std::basic_ostream<CharType, CharTraits>& operator <<
+ (std::basic_ostream<CharType, CharTraits>& stream,
+ const NoPlus& object)
+{
+ return stream << object.value();
+}
+
+void codomain_test()
+{
+ typedef interval_map<int,NoPlus> NoplumT;
+ NoplumT noplum;
+ //noplum.insert(mapping_pair<int,NoPlus>(47,NoPlus(11)));
+ //noplum.insert(mapping_pair<int,NoPlus>(42,NoPlus(14)));
+ //noplum.erase(mapping_pair<int,NoPlus>(42,NoPlus(14)));
+
+ noplum.insert(make_pair(interval<int>::rightopen(2,6),NoPlus(1)));
+ noplum.insert(make_pair(interval<int>::rightopen(4,8),NoPlus(2)));
+
+ cout << noplum << endl;
+}
+
+
+void string_codomain_test()
+{
+ typedef interval_map<int,std::string> ConcaMapT;
+ ConcaMapT cat_map;
+ cat_map += make_pair(interval<int>::rightopen(1,5),std::string("Hello"));
+ cat_map += make_pair(interval<int>::rightopen(3,7),std::string(" World"));
+
+ cout << "cat_map: " << cat_map << endl;
+}
+
+
int main()
{
cout << ">> Interval Template Library: Test meta_functors <<\n";
cout << "-------------------------------------------------------\n";
+ /*
unator1<int, unary> untor1; untor1.speak();
unator2<int, unary<_> > untor2; untor2.speak();
binator1<int, int, binary> bintor1; bintor1.speak();
@@ -175,7 +236,9 @@
PairSet1_int ps1;
template_default_problem();
-
+ */
+ codomain_test();
+ string_codomain_test();
return 0;
}
Modified: sandbox/itl/libs/validate/example/labatea/labatea.cpp
==============================================================================
--- sandbox/itl/libs/validate/example/labatea/labatea.cpp (original)
+++ sandbox/itl/libs/validate/example/labatea/labatea.cpp 2008-12-20 15:30:19 EST (Sat, 20 Dec 2008)
@@ -20,8 +20,8 @@
#include <boost/validate/gentor/gentorprofile.h>
#include <boost/validate/gentor/rangegentor.h>
-#include <boost/validate/typevalidater.h>
-//#include <boost/validate/realmvalidater.h>
+//#include <boost/validate/typevalidater.h>
+#include <boost/validate/realmvalidater.h>
#include <boost/itl/interval_set.hpp>
#include <boost/itl_xt/numbergentor.hpp>
#include <boost/itl_xt/setgentor.hpp>
@@ -82,20 +82,20 @@
void test_realmvalidater()
{
-// RealmValidater validater;
+ RealmValidater validater;
cout <<
">> ------------------------------------------------------ <<\n"
">> -------- Law based test automaton 'LaBatea' ---------- <<\n"
">> Output will be generated in a few seconds\n"
">> terminate by typing <CTRL>C\n"
">> ------------------------------------------------------ <<\n";
-// validater.validate();
+ validater.validate();
};
int main()
{
- test_Validater();
- //test_realmvalidater();
+ //test_Validater();
+ test_realmvalidater();
return 0;
}
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