fixed some KCC stuff and changed less_than_op to tighten up what it provides

[SVN r8383]
This commit is contained in:
Jeremy Siek
2000-12-03 23:17:23 +00:00
parent ffa42dd200
commit e375e4ce47
2 changed files with 62 additions and 72 deletions

View File

@@ -226,23 +226,40 @@ namespace boost {
{ return boolean_archetype(dummy_cons); } { return boolean_archetype(dummy_cons); }
// The purpose of the optags is so that one can specify
// exactly which types the operator< is defined between.
// This is useful for allowing the operations:
//
// A a; B b;
// a < b
// b < a
//
// without also allowing the combinations:
//
// a < a
// b < b
//
struct optag1 { };
struct optag2 { };
struct optag3 { };
#define BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(OP, NAME) \ #define BOOST_DEFINE_BINARY_PREDICATE_ARCHETYPE(OP, NAME) \
template <class Base = null_archetype<> > \ template <class Base = null_archetype<>, class Tag = optag1 > \
class NAME##_first_archetype : public Base { \ class NAME##_first_archetype : public Base { \
public: \ public: \
NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \ NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \
}; \ }; \
\ \
template <class Base = null_archetype<> > \ template <class Base = null_archetype<>, class Tag = optag1 > \
class NAME##_second_archetype : public Base { \ class NAME##_second_archetype : public Base { \
public: \ public: \
NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \ NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \
}; \ }; \
\ \
template <class BaseFirst, class BaseSecond> \ template <class BaseFirst, class BaseSecond, class Tag> \
boolean_archetype \ boolean_archetype \
operator OP (const NAME##_first_archetype<BaseFirst>&, \ operator OP (const NAME##_first_archetype<BaseFirst, Tag>&, \
const NAME##_second_archetype<BaseSecond>&) \ const NAME##_second_archetype<BaseSecond, Tag>&) \
{ \ { \
return boolean_archetype(dummy_cons); \ return boolean_archetype(dummy_cons); \
} }

View File

@@ -122,6 +122,9 @@ namespace power_stuff {
} }
} }
struct tag1 { };
struct tag2 { };
int int
main() main()
{ {
@@ -683,14 +686,14 @@ main()
std::nth_element(ri, ri, ri, comp); std::nth_element(ri, ri, ri, comp);
} }
{ {
#if defined(__KCC) #if defined(__GNUC__)
// The KAI version of this uses a one-argument less-than function
// object.
typedef less_than_comparable_archetype<> FT;
typedef convertible_to_archetype<FT> T;
#else
typedef less_than_op_first_archetype<> FT; typedef less_than_op_first_archetype<> FT;
typedef less_than_op_second_archetype<> T; typedef less_than_op_second_archetype<> T;
#elif defined(__KCC)
// The KAI version of this uses a one-argument less-than function
// object.
typedef less_than_comparable_archetype<> T;
typedef convertible_to_archetype<T> FT;
#endif #endif
forward_iterator_archetype<FT> fi; forward_iterator_archetype<FT> fi;
T value(dummy_cons); T value(dummy_cons);
@@ -708,13 +711,12 @@ main()
} }
{ {
#if defined(__GNUC__) #if defined(__GNUC__)
typedef less_than_op_first_archetype< // Note, order of T,FT is flipped from lower_bound
less_than_op_second_archetype<> > FT; typedef less_than_op_second_archetype<> FT;
typedef less_than_op_second_archetype< typedef less_than_op_first_archetype<> T;
less_than_op_first_archetype<> > T; #elif defined(__KCC)
#else typedef less_than_comparable_archetype<> T;
typedef less_than_op_first_archetype<> FT; typedef convertible_to_archetype<T> FT;
typedef less_than_op_second_archetype<> T;
#endif #endif
forward_iterator_archetype<FT> fi; forward_iterator_archetype<FT> fi;
T value(dummy_cons); T value(dummy_cons);
@@ -723,15 +725,9 @@ main()
{ {
typedef null_archetype<int> Arg1; typedef null_archetype<int> Arg1;
typedef null_archetype<char> Arg2; typedef null_archetype<char> Arg2;
#if defined(__GNUC__) // Note, order of T,FT is flipped from lower_bound
typedef convertible_to_archetype<Arg1, typedef convertible_to_archetype<Arg1> T;
convertible_to_archetype<Arg2> > FT; typedef convertible_to_archetype<Arg2> FT;
typedef convertible_to_archetype<Arg2,
convertible_to_archetype<Arg1> > T;
#else
typedef convertible_to_archetype<Arg1> FT;
typedef convertible_to_archetype<Arg2> T;
#endif
forward_iterator_archetype<FT> fi; forward_iterator_archetype<FT> fi;
T value(dummy_cons); T value(dummy_cons);
binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons); binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons);
@@ -740,12 +736,12 @@ main()
{ {
#if defined(__GNUC__) #if defined(__GNUC__)
typedef less_than_op_first_archetype< typedef less_than_op_first_archetype<
less_than_op_second_archetype<> > FT; less_than_op_second_archetype< null_archetype<>, optag2>, optag1> FT;
typedef less_than_op_second_archetype< typedef less_than_op_second_archetype<
less_than_op_first_archetype<> > T; less_than_op_first_archetype< null_archetype<>, optag2>, optag1> T;
#else #elif defined(__KCC)
typedef less_than_op_first_archetype<> FT; typedef less_than_comparable_archetype<> T;
typedef less_than_op_second_archetype<> T; typedef convertible_to_archetype<T> FT;
#endif #endif
typedef forward_iterator_archetype<FT> FIter; typedef forward_iterator_archetype<FT> FIter;
FIter fi; FIter fi;
@@ -756,15 +752,10 @@ main()
{ {
typedef null_archetype<int> Arg1; typedef null_archetype<int> Arg1;
typedef null_archetype<char> Arg2; typedef null_archetype<char> Arg2;
#if defined(__GNUC__)
typedef convertible_to_archetype<Arg1, typedef convertible_to_archetype<Arg1,
convertible_to_archetype<Arg2> > FT; convertible_to_archetype<Arg2> > FT;
typedef convertible_to_archetype<Arg2, typedef convertible_to_archetype<Arg2,
convertible_to_archetype<Arg1> > T; convertible_to_archetype<Arg1> > T;
#else
typedef convertible_to_archetype<Arg1> FT;
typedef convertible_to_archetype<Arg2> T;
#endif
typedef forward_iterator_archetype<FT> FIter; typedef forward_iterator_archetype<FT> FIter;
FIter fi; FIter fi;
T value(dummy_cons); T value(dummy_cons);
@@ -773,14 +764,14 @@ main()
ignore_unused_variable_warning(p); ignore_unused_variable_warning(p);
} }
{ {
#if defined(__KCC) || defined(__GNUC__) #if defined(__GNUC__)
typedef less_than_op_first_archetype< typedef less_than_op_first_archetype<
less_than_op_second_archetype<> > FT; less_than_op_second_archetype<null_archetype<>, optag2>, optag1> FT;
typedef less_than_op_second_archetype< typedef less_than_op_second_archetype<
less_than_op_first_archetype<> > T; less_than_op_first_archetype<null_archetype<>, optag2>, optag1> T;
#else #elif defined(__KCC)
typedef less_than_op_first_archetype<> FT; typedef less_than_op_first_archetype< less_than_comparable_archetype<> > T;
typedef less_than_op_second_archetype<> T; typedef less_than_op_second_archetype< convertible_to_archetype<T> > FT;
#endif #endif
forward_iterator_archetype<FT> fi; forward_iterator_archetype<FT> fi;
T value(dummy_cons); T value(dummy_cons);
@@ -795,9 +786,6 @@ main()
convertible_to_archetype<Arg2> > FT; convertible_to_archetype<Arg2> > FT;
typedef convertible_to_archetype<Arg2, typedef convertible_to_archetype<Arg2,
convertible_to_archetype<Arg1> > T; convertible_to_archetype<Arg1> > T;
#else
typedef convertible_to_archetype<Arg1> FT;
typedef convertible_to_archetype<Arg2> T;
#endif #endif
typedef forward_iterator_archetype<FT> FIter; typedef forward_iterator_archetype<FT> FIter;
FIter fi; FIter fi;
@@ -808,18 +796,13 @@ main()
} }
{ {
typedef null_archetype<> Tout; typedef null_archetype<> Tout;
#if defined(__GNUC__) #if defined(__GNUC__) || defined(__KCC)
typedef less_than_op_first_archetype< typedef less_than_op_first_archetype<
less_than_op_second_archetype< less_than_op_second_archetype<
convertible_to_archetype<Tout> > > Tin1; convertible_to_archetype<Tout>, optag2>, optag1 > Tin1;
typedef less_than_op_second_archetype< typedef less_than_op_second_archetype<
less_than_op_first_archetype< less_than_op_first_archetype<
convertible_to_archetype<Tout> > > Tin2; convertible_to_archetype<Tout>, optag2> ,optag1> Tin2;
#else
typedef less_than_op_first_archetype<
convertible_to_archetype<Tout> > Tin1;
typedef less_than_op_second_archetype<
convertible_to_archetype<Tout> > Tin2;
#endif #endif
input_iterator_archetype<Tin1> in1; input_iterator_archetype<Tin1> in1;
input_iterator_archetype<Tin2> in2; input_iterator_archetype<Tin2> in2;
@@ -834,18 +817,13 @@ main()
typedef null_archetype<int> Arg1; typedef null_archetype<int> Arg1;
typedef null_archetype<char> Arg2; typedef null_archetype<char> Arg2;
typedef null_archetype<short> Tout; typedef null_archetype<short> Tout;
#if defined(__GNUC__) #if defined(__GNUC__) || defined(__KCC)
typedef convertible_to_archetype<Tout, typedef convertible_to_archetype<Tout,
convertible_to_archetype<Arg1, convertible_to_archetype<Arg1,
convertible_to_archetype<Arg2> > > Tin1; convertible_to_archetype<Arg2> > > Tin1;
typedef convertible_to_archetype<Tout, typedef convertible_to_archetype<Tout,
convertible_to_archetype<Arg2, convertible_to_archetype<Arg2,
convertible_to_archetype<Arg1> > > Tin2; convertible_to_archetype<Arg1> > > Tin2;
#else
typedef convertible_to_archetype<Tout,
convertible_to_archetype<Arg1> > Tin1;
typedef convertible_to_archetype<Tout,
convertible_to_archetype<Arg2> > Tin2;
#endif #endif
input_iterator_archetype<Tin1> in1; input_iterator_archetype<Tin1> in1;
input_iterator_archetype<Tin2> in2; input_iterator_archetype<Tin2> in2;
@@ -872,14 +850,11 @@ main()
std::inplace_merge(bi, bi, bi, comp); std::inplace_merge(bi, bi, bi, comp);
} }
{ {
#if defined(__GNUC__) #if defined(__GNUC__) || defined(__KCC)
typedef less_than_op_first_archetype< typedef less_than_op_first_archetype<
less_than_op_second_archetype<> > Tin1; less_than_op_second_archetype<null_archetype<>, optag1>, optag2> Tin1;
typedef less_than_op_second_archetype< typedef less_than_op_second_archetype<
less_than_op_first_archetype<> > Tin2; less_than_op_first_archetype<null_archetype<>, optag1>, optag2> Tin2;
#else
typedef less_than_op_first_archetype<> Tin1;
typedef less_than_op_second_archetype<> Tin2;
#endif #endif
input_iterator_archetype<Tin1> in1; input_iterator_archetype<Tin1> in1;
input_iterator_archetype<Tin2> in2; input_iterator_archetype<Tin2> in2;
@@ -895,14 +870,11 @@ main()
{ {
typedef null_archetype<int> Arg1; typedef null_archetype<int> Arg1;
typedef null_archetype<char> Arg2; typedef null_archetype<char> Arg2;
#if defined(__GNUC__) #if defined(__GNUC__) || defined(__KCC)
typedef convertible_to_archetype<Arg1, typedef convertible_to_archetype<Arg1,
convertible_to_archetype<Arg2> > Tin1; convertible_to_archetype<Arg2> > Tin1;
typedef convertible_to_archetype<Arg2, typedef convertible_to_archetype<Arg2,
convertible_to_archetype<Arg1> > Tin2; convertible_to_archetype<Arg1> > Tin2;
#else
typedef convertible_to_archetype<Arg1> Tin1;
typedef convertible_to_archetype<Arg2> Tin2;
#endif #endif
input_iterator_archetype<Tin1> in1; input_iterator_archetype<Tin1> in1;
input_iterator_archetype<Tin2> in2; input_iterator_archetype<Tin2> in2;
@@ -917,7 +889,8 @@ main()
#endif #endif
} }
{ {
typedef sgi_assignable_archetype< less_than_comparable_archetype<> > T; typedef sgi_assignable_archetype<
less_than_comparable_archetype<> > T;
random_access_iterator_archetype<T> ri; random_access_iterator_archetype<T> ri;
std::push_heap(ri, ri); std::push_heap(ri, ri);
std::pop_heap(ri, ri); std::pop_heap(ri, ri);