diff --git a/include/boost/pending/concept_archetypes.hpp b/include/boost/pending/concept_archetypes.hpp index e11d30a..994e149 100644 --- a/include/boost/pending/concept_archetypes.hpp +++ b/include/boost/pending/concept_archetypes.hpp @@ -224,25 +224,42 @@ namespace boost { operator>=(const comparable_archetype&, const comparable_archetype&) { 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) \ - template > \ + template , class Tag = optag1 > \ class NAME##_first_archetype : public Base { \ public: \ NAME##_first_archetype(detail::dummy_constructor x) : Base(x) { } \ }; \ \ - template > \ + template , class Tag = optag1 > \ class NAME##_second_archetype : public Base { \ public: \ NAME##_second_archetype(detail::dummy_constructor x) : Base(x) { } \ }; \ \ - template \ + template \ boolean_archetype \ - operator OP (const NAME##_first_archetype&, \ - const NAME##_second_archetype&) \ + operator OP (const NAME##_first_archetype&, \ + const NAME##_second_archetype&) \ { \ return boolean_archetype(dummy_cons); \ } diff --git a/stl_concept_covering.cpp b/stl_concept_covering.cpp index a0eab59..a32a644 100644 --- a/stl_concept_covering.cpp +++ b/stl_concept_covering.cpp @@ -122,6 +122,9 @@ namespace power_stuff { } } +struct tag1 { }; +struct tag2 { }; + int main() { @@ -683,14 +686,14 @@ main() std::nth_element(ri, ri, ri, comp); } { -#if defined(__KCC) - // The KAI version of this uses a one-argument less-than function - // object. - typedef less_than_comparable_archetype<> FT; - typedef convertible_to_archetype T; -#else +#if defined(__GNUC__) typedef less_than_op_first_archetype<> FT; 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 FT; #endif forward_iterator_archetype fi; T value(dummy_cons); @@ -708,13 +711,12 @@ main() } { #if defined(__GNUC__) - typedef less_than_op_first_archetype< - less_than_op_second_archetype<> > FT; - typedef less_than_op_second_archetype< - less_than_op_first_archetype<> > T; -#else - typedef less_than_op_first_archetype<> FT; - typedef less_than_op_second_archetype<> T; + // Note, order of T,FT is flipped from lower_bound + typedef less_than_op_second_archetype<> FT; + typedef less_than_op_first_archetype<> T; +#elif defined(__KCC) + typedef less_than_comparable_archetype<> T; + typedef convertible_to_archetype FT; #endif forward_iterator_archetype fi; T value(dummy_cons); @@ -723,15 +725,9 @@ main() { typedef null_archetype Arg1; typedef null_archetype Arg2; -#if defined(__GNUC__) - typedef convertible_to_archetype > FT; - typedef convertible_to_archetype > T; -#else - typedef convertible_to_archetype FT; - typedef convertible_to_archetype T; -#endif + // Note, order of T,FT is flipped from lower_bound + typedef convertible_to_archetype T; + typedef convertible_to_archetype FT; forward_iterator_archetype fi; T value(dummy_cons); binary_predicate_archetype comp(dummy_cons); @@ -740,12 +736,12 @@ main() { #if defined(__GNUC__) 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< - less_than_op_first_archetype<> > T; -#else - typedef less_than_op_first_archetype<> FT; - typedef less_than_op_second_archetype<> T; + less_than_op_first_archetype< null_archetype<>, optag2>, optag1> T; +#elif defined(__KCC) + typedef less_than_comparable_archetype<> T; + typedef convertible_to_archetype FT; #endif typedef forward_iterator_archetype FIter; FIter fi; @@ -756,15 +752,10 @@ main() { typedef null_archetype Arg1; typedef null_archetype Arg2; -#if defined(__GNUC__) typedef convertible_to_archetype > FT; typedef convertible_to_archetype > T; -#else - typedef convertible_to_archetype FT; - typedef convertible_to_archetype T; -#endif typedef forward_iterator_archetype FIter; FIter fi; T value(dummy_cons); @@ -773,14 +764,14 @@ main() ignore_unused_variable_warning(p); } { -#if defined(__KCC) || defined(__GNUC__) +#if defined(__GNUC__) typedef less_than_op_first_archetype< - less_than_op_second_archetype<> > FT; + less_than_op_second_archetype, optag2>, optag1> FT; typedef less_than_op_second_archetype< - less_than_op_first_archetype<> > T; -#else - typedef less_than_op_first_archetype<> FT; - typedef less_than_op_second_archetype<> T; + less_than_op_first_archetype, optag2>, optag1> T; +#elif defined(__KCC) + typedef less_than_op_first_archetype< less_than_comparable_archetype<> > T; + typedef less_than_op_second_archetype< convertible_to_archetype > FT; #endif forward_iterator_archetype fi; T value(dummy_cons); @@ -795,9 +786,6 @@ main() convertible_to_archetype > FT; typedef convertible_to_archetype > T; -#else - typedef convertible_to_archetype FT; - typedef convertible_to_archetype T; #endif typedef forward_iterator_archetype FIter; FIter fi; @@ -808,18 +796,13 @@ main() } { typedef null_archetype<> Tout; -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__KCC) typedef less_than_op_first_archetype< less_than_op_second_archetype< - convertible_to_archetype > > Tin1; + convertible_to_archetype, optag2>, optag1 > Tin1; typedef less_than_op_second_archetype< less_than_op_first_archetype< - convertible_to_archetype > > Tin2; -#else - typedef less_than_op_first_archetype< - convertible_to_archetype > Tin1; - typedef less_than_op_second_archetype< - convertible_to_archetype > Tin2; + convertible_to_archetype, optag2> ,optag1> Tin2; #endif input_iterator_archetype in1; input_iterator_archetype in2; @@ -834,18 +817,13 @@ main() typedef null_archetype Arg1; typedef null_archetype Arg2; typedef null_archetype Tout; -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__KCC) typedef convertible_to_archetype > > Tin1; typedef convertible_to_archetype > > Tin2; -#else - typedef convertible_to_archetype > Tin1; - typedef convertible_to_archetype > Tin2; #endif input_iterator_archetype in1; input_iterator_archetype in2; @@ -872,14 +850,11 @@ main() std::inplace_merge(bi, bi, bi, comp); } { -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__KCC) typedef less_than_op_first_archetype< - less_than_op_second_archetype<> > Tin1; + less_than_op_second_archetype, optag1>, optag2> Tin1; typedef less_than_op_second_archetype< - less_than_op_first_archetype<> > Tin2; -#else - typedef less_than_op_first_archetype<> Tin1; - typedef less_than_op_second_archetype<> Tin2; + less_than_op_first_archetype, optag1>, optag2> Tin2; #endif input_iterator_archetype in1; input_iterator_archetype in2; @@ -895,14 +870,11 @@ main() { typedef null_archetype Arg1; typedef null_archetype Arg2; -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__KCC) typedef convertible_to_archetype > Tin1; typedef convertible_to_archetype > Tin2; -#else - typedef convertible_to_archetype Tin1; - typedef convertible_to_archetype Tin2; #endif input_iterator_archetype in1; input_iterator_archetype in2; @@ -917,7 +889,8 @@ main() #endif } { - typedef sgi_assignable_archetype< less_than_comparable_archetype<> > T; + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; random_access_iterator_archetype ri; std::push_heap(ri, ri); std::pop_heap(ri, ri);