Remove bind/compose/swap functor adaptors.

We use boost::bind instead now.
This commit is contained in:
Michael Hoffmann 2008-06-19 11:03:40 +00:00
parent f0eefae126
commit d92021ba08
3 changed files with 38 additions and 245 deletions

View File

@ -26,6 +26,8 @@
#ifndef CGAL_FUNCTIONAL_H
#define CGAL_FUNCTIONAL_H 1
#ifndef CGAL_NO_DEPRECATED_CODE
#include <CGAL/functional_base.h>
CGAL_BEGIN_NAMESPACE
@ -149,6 +151,7 @@ struct Set_arity {
};
template < class F >
CGAL_DEPRECATED
inline
typename Set_arity< F, 0 >::Type
set_arity_0(const F& f)
@ -158,6 +161,7 @@ set_arity_0(const F& f)
}
template < class F >
CGAL_DEPRECATED
inline
typename Set_arity< F, 1 >::Type
set_arity_1(const F& f)
@ -167,6 +171,7 @@ set_arity_1(const F& f)
}
template < class F >
CGAL_DEPRECATED
inline
typename Set_arity< F, 2 >::Type
set_arity_2(const F& f)
@ -176,6 +181,7 @@ set_arity_2(const F& f)
}
template < class F >
CGAL_DEPRECATED
inline
typename Set_arity< F, 3 >::Type
set_arity_3(const F& f)
@ -185,6 +191,7 @@ set_arity_3(const F& f)
}
template < class F >
CGAL_DEPRECATED
inline
typename Set_arity< F, 4 >::Type
set_arity_4(const F& f)
@ -194,6 +201,7 @@ set_arity_4(const F& f)
}
template < class F >
CGAL_DEPRECATED
inline
typename Set_arity< F, 5 >::Type
set_arity_5(const F& f)
@ -383,29 +391,33 @@ struct Swap {
typedef CGALi::Swapper< F, i, typename Arity_traits< F >::Arity > Type;
};
template < class F > inline
typename Swap< F, 1 >::Type
template < class F >
CGAL_DEPRECATED
inline typename Swap< F, 1 >::Type
swap_1(const F& f) {
typedef typename Swap< F, 1 >::Type S;
return S(f);
}
template < class F > inline
typename Swap< F, 2 >::Type
template < class F >
CGAL_DEPRECATED
inline typename Swap< F, 2 >::Type
swap_2(const F& f) {
typedef typename Swap< F, 2 >::Type S;
return S(f);
}
template < class F > inline
typename Swap< F, 3 >::Type
template < class F >
CGAL_DEPRECATED
inline typename Swap< F, 3 >::Type
swap_3(const F& f) {
typedef typename Swap< F, 3 >::Type S;
return S(f);
}
template < class F > inline
typename Swap< F, 4 >::Type
template < class F >
CGAL_DEPRECATED
inline typename Swap< F, 4 >::Type
swap_4(const F& f) {
typedef typename Swap< F, 4 >::Type S;
return S(f);
@ -685,6 +697,7 @@ struct Bind {
typedef CGALi::Binder< T, typename Arity_traits< T >::Arity, A, i > Type;
};
template < class F, class A >
CGAL_DEPRECATED
inline typename Bind< F, A, 1 >::Type
bind_1(const F& f, const A& a) {
typedef typename Bind< F, A, 1 >::Type B;
@ -692,6 +705,7 @@ bind_1(const F& f, const A& a) {
}
template < class F, class A >
CGAL_DEPRECATED
inline typename Bind< F, A, 2 >::Type
bind_2(const F& f, const A& a) {
typedef typename Bind< F, A, 2 >::Type B;
@ -699,6 +713,7 @@ bind_2(const F& f, const A& a) {
}
template < class F, class A >
CGAL_DEPRECATED
inline typename Bind< F, A, 3 >::Type
bind_3(const F& f, const A& a) {
typedef typename Bind< F, A, 3 >::Type B;
@ -706,6 +721,7 @@ bind_3(const F& f, const A& a) {
}
template < class F, class A >
CGAL_DEPRECATED
inline typename Bind< F, A, 4 >::Type
bind_4(const F& f, const A& a) {
typedef typename Bind< F, A, 4 >::Type B;
@ -713,6 +729,7 @@ bind_4(const F& f, const A& a) {
}
template < class F, class A >
CGAL_DEPRECATED
inline typename Bind< F, A, 5 >::Type
bind_5(const F& f, const A& a) {
typedef typename Bind< F, A, 5 >::Type B;
@ -3243,6 +3260,7 @@ struct Compose_shared {
// ------------------------------------------------------------------------
template < class F0, class F1 >
CGAL_DEPRECATED
inline typename Compose< F0, F1 >::Type
compose(const F0& f0, const F1& f1) {
typedef typename Compose< F0, F1 >::Type C;
@ -3250,6 +3268,7 @@ compose(const F0& f0, const F1& f1) {
}
template < class F0, class F1, class F2 >
CGAL_DEPRECATED
inline typename Compose< F0, F1, F2 >::Type
compose(const F0& f0, const F1& f1, const F2& f2)
{
@ -3258,6 +3277,7 @@ compose(const F0& f0, const F1& f1, const F2& f2)
}
template < class F0, class F1, class F2 >
CGAL_DEPRECATED
inline typename Compose_shared< F0, F1, F2 >::Type
compose_shared(const F0& f0, const F1& f1, const F2& f2)
{
@ -3266,6 +3286,7 @@ compose_shared(const F0& f0, const F1& f1, const F2& f2)
}
template < class F0, class F1, class F2, class F3 >
CGAL_DEPRECATED
inline typename Compose< F0, F1, F2, F3 >::Type
compose(const F0& f0, const F1& f1, const F2& f2, const F3& f3)
{
@ -3274,6 +3295,7 @@ compose(const F0& f0, const F1& f1, const F2& f2, const F3& f3)
}
template < class F0, class F1, class F2, class F3 >
CGAL_DEPRECATED
inline typename Compose_shared< F0, F1, F2, F3 >::Type
compose_shared(const F0& f0, const F1& f1, const F2& f2, const F3& f3)
{
@ -3282,7 +3304,9 @@ compose_shared(const F0& f0, const F1& f1, const F2& f2, const F3& f3)
}
// adaptor for not/negation
template < typename F > inline
template < typename F >
CGAL_DEPRECATED
inline
typename Compose< std::logical_not<typename F::result_type>, F >::Type
negate(const F& f)
{
@ -3291,6 +3315,8 @@ negate(const F& f)
CGAL_END_NAMESPACE
#endif // !def CGAL_NO_DEPRECATED_CODE
#endif // CGAL_FUNCTIONAL_H //
// EOF //

View File

@ -1,3 +1,6 @@
19 June 2008 Michael Hoffmann
- deprecate bind/compose/swap functor adaptors
17 February 2007 Andreas Meyer
- added a mpl struct is_same_or_derived<A,B> similar to
boost::is_same / boost::is_base_and_derived

View File

@ -1,236 +0,0 @@
#include <CGAL/basic.h>
#include <CGAL/functional.h>
#include <algorithm>
using CGAL::set_arity_0;
using CGAL::set_arity_1;
using CGAL::set_arity_2;
using CGAL::set_arity_3;
using CGAL::set_arity_4;
using CGAL::set_arity_5;
using CGAL::swap_1;
using CGAL::swap_2;
using CGAL::swap_3;
using CGAL::swap_4;
using CGAL::bind_1;
using CGAL::bind_2;
using CGAL::bind_3;
using CGAL::bind_4;
using CGAL::bind_5;
using CGAL::compose;
using CGAL::compose_shared;
using std::equal_to;
using std::cout;
using std::endl;
struct F0 {
typedef CGAL::Arity_tag< 0 > Arity;
typedef int result_type;
int operator()() const { return 2; }
};
struct F1 {
typedef CGAL::Arity_tag< 1 > Arity;
typedef int result_type;
int operator()(int x) const { return x*2; }
};
struct F2 {
typedef CGAL::Arity_tag< 2 > Arity;
typedef int result_type;
int operator()(int x, int y) const { return x+y; }
};
struct F3 {
typedef CGAL::Arity_tag< 3 > Arity;
typedef int result_type;
int operator()(int x, int y, int z) const { return (x+z)*y; }
};
struct F4 {
typedef CGAL::Arity_tag< 4 > Arity;
typedef int result_type;
int operator()(int x, int y, int z, int k) const
{ return x*z-y*k; }
};
struct F5 {
typedef CGAL::Arity_tag< 5 > Arity;
typedef int result_type;
int operator()(int x, int y, int z, int k, int l) const
{ return (x-k)*(l-z)*y; }
};
int main()
{
F0 f0;
F1 f1;
F2 f2;
F3 f3;
F4 f4;
F5 f5;
// test set arity
cout << set_arity_0(f0)() << endl;
cout << set_arity_1(f1)(1) << endl;
cout << set_arity_2(f2)(1, 2) << endl;
cout << set_arity_3(f3)(1, 2, 3) << endl;
cout << set_arity_4(f4)(1, 2, 3, 4) << endl;
cout << set_arity_5(f5)(1, 2, 3, 4, 5) << endl;
// test binders
cout << bind_1(f1, 2)() << endl;
cout << bind_1(f2, 2)(7) << endl;
cout << bind_1(f3, 2)(3, 4) << endl;
cout << bind_1(f4, 2)(3, 4, 5) << endl;
cout << bind_1(f5, 2)(3, 4, 5, 6) << endl;
cout << bind_2(f2, 2)(7) << endl;
cout << bind_2(f3, 2)(3, 4) << endl;
cout << bind_2(f4, 2)(3, 4, 5) << endl;
cout << bind_2(f5, 2)(3, 4, 5, 6) << endl;
cout << bind_3(f3, 2)(3, 4) << endl;
cout << bind_3(f4, 2)(3, 4, 5) << endl;
cout << bind_3(f5, 2)(3, 4, 5, 6) << endl;
cout << bind_4(f4, 2)(3, 4, 5) << endl;
cout << bind_4(f5, 2)(3, 4, 5, 6) << endl;
cout << bind_5(f5, 2)(3, 4, 5, 6) << endl;
// test composers
cout << compose(f1, f0)() << endl;
cout << compose(f1, f1)(2) << endl;
cout << compose(f1, f2)(2, 3) << endl;
cout << compose(f1, f3)(2, 3, 4) << endl;
cout << compose(f1, f4)(2, 3, 4, 5) << endl;
cout << compose(f1, f5)(2, 3, 4, 5, 6) << endl;
cout << compose(f2, f0, f0)() << endl;
cout << compose(f2, f0, f1)(2) << endl;
cout << compose(f2, f1, f0)(2) << endl;
cout << compose(f2, f0, f1)(2) << endl;
cout << compose(f2, f0, f2)(2, 3) << endl;
cout << compose(f2, f2, f0)(2, 3) << endl;
cout << compose(f2, f1, f1)(2, 3) << endl;
cout << compose(f2, f3, f0)(2, 3, 4) << endl;
cout << compose(f2, f0, f3)(2, 3, 4) << endl;
cout << compose(f2, f2, f1)(2, 3, 4) << endl;
cout << compose(f2, f1, f2)(2, 3, 4) << endl;
cout << compose(f2, f4, f0)(2, 3, 4, 5) << endl;
cout << compose(f2, f0, f4)(2, 3, 4, 5) << endl;
cout << compose(f2, f3, f1)(2, 3, 4, 5) << endl;
cout << compose(f2, f1, f3)(2, 3, 4, 5) << endl;
cout << compose(f2, f2, f2)(2, 3, 4, 5) << endl;
cout << compose(f2, f5, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f2, f0, f5)(2, 3, 4, 5, 6) << endl;
cout << compose(f2, f4, f1)(2, 3, 4, 5, 6) << endl;
cout << compose(f2, f1, f4)(2, 3, 4, 5, 6) << endl;
cout << compose(f2, f3, f2)(2, 3, 4, 5, 6) << endl;
cout << compose(f2, f2, f3)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f0, f0)() << endl;
cout << compose(f3, f1, f0, f0)(2) << endl;
cout << compose(f3, f0, f1, f0)(2) << endl;
cout << compose(f3, f0, f0, f1)(2) << endl;
cout << compose(f3, f2, f0, f0)(2, 3) << endl;
cout << compose(f3, f0, f2, f0)(2, 3) << endl;
cout << compose(f3, f0, f0, f2)(2, 3) << endl;
cout << compose(f3, f1, f1, f0)(2, 3) << endl;
cout << compose(f3, f1, f0, f1)(2, 3) << endl;
cout << compose(f3, f0, f1, f1)(2, 3) << endl;
cout << compose(f3, f3, f0, f0)(2, 3, 4) << endl;
cout << compose(f3, f0, f3, f0)(2, 3, 4) << endl;
cout << compose(f3, f0, f0, f3)(2, 3, 4) << endl;
cout << compose(f3, f2, f1, f0)(2, 3, 4) << endl;
cout << compose(f3, f2, f0, f1)(2, 3, 4) << endl;
cout << compose(f3, f1, f2, f0)(2, 3, 4) << endl;
cout << compose(f3, f0, f2, f1)(2, 3, 4) << endl;
cout << compose(f3, f1, f0, f2)(2, 3, 4) << endl;
cout << compose(f3, f0, f1, f2)(2, 3, 4) << endl;
cout << compose(f3, f1, f1, f1)(2, 3, 4) << endl;
cout << compose(f3, f4, f0, f0)(2, 3, 4, 5) << endl;
cout << compose(f3, f0, f4, f0)(2, 3, 4, 5) << endl;
cout << compose(f3, f0, f0, f4)(2, 3, 4, 5) << endl;
cout << compose(f3, f3, f1, f0)(2, 3, 4, 5) << endl;
cout << compose(f3, f3, f0, f1)(2, 3, 4, 5) << endl;
cout << compose(f3, f1, f3, f0)(2, 3, 4, 5) << endl;
cout << compose(f3, f0, f3, f1)(2, 3, 4, 5) << endl;
cout << compose(f3, f1, f0, f3)(2, 3, 4, 5) << endl;
cout << compose(f3, f0, f1, f3)(2, 3, 4, 5) << endl;
cout << compose(f3, f2, f2, f0)(2, 3, 4, 5) << endl;
cout << compose(f3, f2, f0, f2)(2, 3, 4, 5) << endl;
cout << compose(f3, f0, f2, f2)(2, 3, 4, 5) << endl;
cout << compose(f3, f2, f1, f1)(2, 3, 4, 5) << endl;
cout << compose(f3, f1, f2, f1)(2, 3, 4, 5) << endl;
cout << compose(f3, f1, f1, f2)(2, 3, 4, 5) << endl;
cout << compose(f3, f5, f0, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f5, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f0, f5)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f4, f1, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f4, f0, f1)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f4, f1)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f1, f4, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f1, f4)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f1, f0, f4)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f3, f2, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f3, f0, f2)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f3, f2)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f2, f3, f0)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f0, f2, f3)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f2, f0, f3)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f3, f1, f1)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f1, f3, f1)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f1, f1, f3)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f2, f2, f1)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f2, f1, f2)(2, 3, 4, 5, 6) << endl;
cout << compose(f3, f1, f2, f2)(2, 3, 4, 5, 6) << endl;
cout << compose_shared(f2, f5, f5)(2, 3, 4, 5, 6) << endl;
cout << compose_shared(f2, f4, f4)(2, 3, 4, 5) << endl;
cout << compose_shared(f2, f3, f3)(2, 3, 4) << endl;
cout << compose_shared(f2, f2, f2)(2, 3) << endl;
cout << compose_shared(f2, f1, f1)(2) << endl;
cout << compose_shared(f2, f0, f0)() << endl;
cout << compose_shared(f3, f5, f5, f5)(2, 3, 4, 5, 6) << endl;
cout << compose_shared(f3, f4, f4, f4)(2, 3, 4, 5) << endl;
cout << compose_shared(f3, f3, f3, f3)(2, 3, 4) << endl;
cout << compose_shared(f3, f2, f2, f2)(2, 3) << endl;
cout << compose_shared(f3, f1, f1, f1)(2) << endl;
cout << compose_shared(f3, f0, f0, f0)() << endl;
cout << swap_1(f2)(1, 2) << endl;
cout << swap_1(f3)(1, 2, 3) << endl;
cout << swap_1(f4)(1, 2, 3, 4) << endl;
cout << swap_1(f5)(1, 2, 3, 4, 5) << endl;
cout << swap_2(f3)(1, 2, 3) << endl;
cout << swap_2(f4)(1, 2, 3, 4) << endl;
cout << swap_2(f5)(1, 2, 3, 4, 5) << endl;
cout << swap_3(f4)(1, 2, 3, 4) << endl;
cout << swap_3(f5)(1, 2, 3, 4, 5) << endl;
cout << swap_4(f5)(1, 2, 3, 4, 5) << endl;
if (!(swap_1(f2)(1, 2) == f2(2, 1))) return 1;
if (!(swap_1(f3)(1, 2, 3) == f3(2, 1, 3))) return 1;
if (!(swap_1(f4)(1, 2, 3, 4) == f4(2, 1, 3, 4))) return 1;
if (!(swap_1(f5)(1, 2, 3, 4, 5) == f5(2, 1, 3, 4, 5))) return 1;
if (!(swap_2(f3)(1, 2, 3) == f3(1, 3, 2))) return 1;
if (!(swap_2(f4)(1, 2, 3, 4) == f4(1, 3, 2, 4))) return 1;
if (!(swap_2(f5)(1, 2, 3, 4, 5) == f5(1, 3, 2, 4, 5))) return 1;
if (!(swap_3(f4)(1, 2, 3, 4) == f4(1, 2, 4, 3))) return 1;
if (!(swap_3(f5)(1, 2, 3, 4, 5) == f5(1, 2, 4, 3, 5))) return 1;
if (!(swap_4(f5)(1, 2, 3, 4, 5) == f5(1, 2, 3, 5, 4))) return 1;
// negate
equal_to<int> eq;
int a[] = {1,2,3,4,5,6,7};
int b[] = {2,1,4,5,3,6,8};
std::pair<int*,int*> pp = std::mismatch(a, a+7, b, CGAL::negate(eq));
if (pp.first != a+5 || pp.second != b+5) return 1;
// test combination
cout << bind_1(swap_1(f2), 5)(1) << endl;
cout << bind_1(swap_2(f3), 5)(1, 2) << endl;
cout << bind_1(swap_3(f4), 5)(1, 2, 3) << endl;
cout << bind_1(swap_4(f5), 5)(1, 2, 3, 4) << endl;
cout << compose(swap_1(f2), swap_1(f2), swap_2(f3))(1, 2, 3, 4, 5) << endl;
cout << compose(bind_1(f2, 5), bind_3(f4, 4))(1, 2, 3) << endl;
return 0;
}