From cc25398b06629347a7f4d219bb23acc5cc90c7fc Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Fri, 6 Feb 2004 05:47:22 +0000 Subject: [PATCH] updating with respect to change in input_iterator_archetype [SVN r22183] --- stl_concept_covering.cpp | 197 ++++++++++++++------------------------- 1 file changed, 72 insertions(+), 125 deletions(-) diff --git a/stl_concept_covering.cpp b/stl_concept_covering.cpp index 171affa..365f4a3 100644 --- a/stl_concept_covering.cpp +++ b/stl_concept_covering.cpp @@ -93,22 +93,19 @@ namespace boost { // so Koenig lookup will find // for std::partial_sum and adj_diff namespace part_sum { - typedef boost::null_archetype<> Tout; - typedef boost::sgi_assignable_archetype< - boost::convertible_to_archetype > Ret; - class Tin { + class T { public: - Tin(const Ret&) { } - Tin(boost::detail::dummy_constructor x) { } - operator const Tout&() const { return boost::static_object::get(); } + typedef boost::sgi_assignable_archetype<> Ret; + T(const Ret&) { } + T(boost::detail::dummy_constructor x) { } private: - Tin() { } + T() { } }; - Ret operator+(const Tin&, const Tin&) { - return Ret(dummy_cons); + T::Ret operator+(const T&, const T&) { + return T::Ret(dummy_cons); } - Ret operator-(const Tin&, const Tin&) { - return Ret(dummy_cons); + T::Ret operator-(const T&, const T&) { + return T::Ret(dummy_cons); } } @@ -130,6 +127,7 @@ namespace power_stuff { struct tag1 { }; struct tag2 { }; + int main() { @@ -138,12 +136,12 @@ main() //=========================================================================== // Non-mutating Algorithms { - input_iterator_archetype< - convertible_to_archetype< null_archetype<> > > in; + input_iterator_archetype< null_archetype<> > in; unary_function_archetype< null_archetype<> , null_archetype<> > f(dummy_cons); std::for_each(in, in, f); } + // gcc bug { typedef equality_comparable2_first_archetype<> Left; input_iterator_archetype< Left > in; @@ -151,9 +149,9 @@ main() in = std::find(in, in, value); } { - input_iterator_archetype< - convertible_to_archetype< null_archetype<> > > in; - unary_predicate_archetype< null_archetype<> > pred(dummy_cons); + typedef null_archetype<> T; + input_iterator_archetype in; + unary_predicate_archetype pred(dummy_cons); in = std::find_if(in, in, pred); } { @@ -167,6 +165,7 @@ main() pred(dummy_cons); fo = std::adjacent_find(fo, fo, pred); } + // gcc bug { typedef equal_op_first_archetype<> Left; input_iterator_archetype in; @@ -185,14 +184,14 @@ main() ignore_unused_variable_warning(n); } { - typedef input_iterator_archetype< - convertible_to_archetype > > InIter; + typedef input_iterator_archetype< null_archetype<> > InIter; InIter in; unary_predicate_archetype > pred(dummy_cons); std::iterator_traits::difference_type n = std::count_if(in, in, pred); ignore_unused_variable_warning(n); } + // gcc bug { typedef equal_op_first_archetype<> Left; typedef input_iterator_archetype InIter1; @@ -204,14 +203,14 @@ main() ignore_unused_variable_warning(p); } { - typedef input_iterator_archetype< - convertible_to_archetype > > InIter; + typedef input_iterator_archetype > InIter; InIter in1, in2; binary_predicate_archetype , null_archetype<> > pred(dummy_cons); std::pair p = std::mismatch(in1, in1, in2, pred); ignore_unused_variable_warning(p); } + // gcc bug { typedef equality_comparable2_first_archetype<> Left; input_iterator_archetype in1; @@ -221,7 +220,7 @@ main() ignore_unused_variable_warning(b); } { - input_iterator_archetype< convertible_to_archetype > > + input_iterator_archetype< null_archetype<> > in1, in2; binary_predicate_archetype , null_archetype<> > pred(dummy_cons); @@ -286,10 +285,9 @@ main() // Mutating Algorithms { - typedef null_archetype<> OutT; - typedef convertible_to_archetype InT; - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); + typedef null_archetype<> T; + input_iterator_archetype in; + output_iterator_archetype out(dummy_cons); out = std::copy(in, in, out); } { @@ -316,8 +314,8 @@ main() fi2 = std::swap_ranges(fi1, fi1, fi2); } { - typedef convertible_to_archetype > Tin; - typedef null_archetype<> Tout; + typedef null_archetype Tin; + typedef null_archetype Tout; input_iterator_archetype in; output_iterator_archetype out(dummy_cons); unary_function_archetype , @@ -325,13 +323,13 @@ main() out = std::transform(in, in, out, op); } { - typedef convertible_to_archetype > Tin1; - typedef convertible_to_archetype > Tin2; - typedef null_archetype<> Tout; + typedef null_archetype Tin1; + typedef null_archetype Tin2; + typedef null_archetype Tout; input_iterator_archetype in1; input_iterator_archetype in2; output_iterator_archetype out(dummy_cons); - binary_function_archetype, null_archetype, + binary_function_archetype > op(dummy_cons); out = std::transform(in1, in1, in2, out, op); } @@ -352,8 +350,8 @@ main() convertible_to_archetype value(dummy_cons); std::replace_if(fi, fi, pred, value); } + // gcc bug { -#if 0 // Issue, the use of ?: inside replace_copy() complicates things typedef equal_op_first_archetype<> Tin; typedef null_archetype<> Tout; @@ -362,33 +360,15 @@ main() output_iterator_archetype out(dummy_cons); T value(dummy_cons); out = std::replace_copy(in, in, out, value, value); -#else - typedef null_archetype<> Tout; - typedef equal_op_second_archetype< convertible_to_archetype > T; - // Adding convertible to T for Tin solves the problem, so would - // making T convertible to Tin. Not sure what the right way to - // express the requirement would be. Also, perhaps the - // implementation's use of ?: is invalid. - typedef equal_op_first_archetype< convertible_to_archetype > Tin; - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); - T value(dummy_cons); - out = std::replace_copy(in, in, out, value, value); -#endif } { // The issue of ?: also affects this function - typedef null_archetype PredArg; - typedef null_archetype Tout; - typedef convertible_to_archetype > T; - typedef convertible_to_archetype > > Tin; + typedef null_archetype<> Tout; + typedef assignable_archetype< convertible_to_archetype > Tin; input_iterator_archetype in; output_iterator_archetype out(dummy_cons); - unary_predicate_archetype pred(dummy_cons); - T value(dummy_cons); + unary_predicate_archetype pred(dummy_cons); + Tin value(dummy_cons); out = std::replace_copy_if(in, in, out, pred, value); } { @@ -435,6 +415,7 @@ main() unary_predicate_archetype pred(dummy_cons); fi = std::remove_if(fi, fi, pred); } + // gcc bug { typedef null_archetype<> Tout; typedef equality_comparable2_first_archetype< @@ -446,13 +427,10 @@ main() out = std::remove_copy(in, in, out, value); } { - typedef null_archetype Tout; - typedef null_archetype PredArg; - typedef convertible_to_archetype > Tin; - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); - unary_predicate_archetype pred(dummy_cons); + typedef null_archetype<> T; + input_iterator_archetype in; + output_iterator_archetype out(dummy_cons); + unary_predicate_archetype pred(dummy_cons); out = std::remove_copy_if(in, in, out, pred); } { @@ -470,6 +448,7 @@ main() binary_predicate_archetype pred(dummy_cons); fi = std::unique(fi, fi, pred); } + // gcc bug { typedef equality_comparable_archetype< sgi_assignable_archetype<> > T; input_iterator_archetype in; @@ -477,16 +456,10 @@ main() out = std::unique_copy(in, in, out); } { - typedef null_archetype Arg1; - typedef null_archetype Arg2; - typedef null_archetype Tout; - typedef sgi_assignable_archetype< - convertible_to_archetype > > > Tin; - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); - binary_predicate_archetype pred(dummy_cons); + typedef sgi_assignable_archetype<> T; + input_iterator_archetype in; + output_iterator_archetype out(dummy_cons); + binary_predicate_archetype pred(dummy_cons); out = std::unique_copy(in, in, out, pred); } { @@ -585,6 +558,7 @@ main() binary_predicate_archetype comp(dummy_cons); std::partial_sort(ri, ri, ri, comp); } + // gcc bug { // This could be formulated so that the two iterators are not // required to have the same value type, but it is messy. @@ -595,12 +569,10 @@ main() ri_out = std::partial_sort_copy(in, in , ri_out, ri_out); } { - typedef null_archetype<> Arg; - typedef sgi_assignable_archetype< - convertible_to_archetype > T; + typedef sgi_assignable_archetype<> T; input_iterator_archetype in; mutable_random_access_iterator_archetype ri_out; - binary_predicate_archetype comp(dummy_cons); + binary_predicate_archetype comp(dummy_cons); ri_out = std::partial_sort_copy(in, in , ri_out, ri_out, comp); } { @@ -737,6 +709,7 @@ main() less_than_op_first_archetype< convertible_to_archetype, optag2> ,optag1> Tin2; #endif + // gcc bug input_iterator_archetype in1; input_iterator_archetype in2; output_iterator_archetype out(dummy_cons); @@ -747,21 +720,12 @@ main() out = std::set_symmetric_difference(in1, in1, in2, in2, out); } { - typedef null_archetype Arg1; - typedef null_archetype Arg2; - typedef null_archetype Tout; -#if defined(__GNUC__) || defined(__KCC) - typedef convertible_to_archetype > > Tin1; - typedef convertible_to_archetype > > Tin2; -#endif - input_iterator_archetype in1; - input_iterator_archetype in2; - output_iterator_archetype out(dummy_cons); - binary_predicate_archetype comp(dummy_cons); + typedef null_archetype<> T; + input_iterator_archetype in1; + input_iterator_archetype in2; + typedef convertible_from_archetype Tout; + output_iterator_archetype out(dummy_cons); + binary_predicate_archetype comp(dummy_cons); out = std::merge(in1, in1, in2, in2, out, comp); out = std::set_union(in1, in1, in2, in2, out, comp); out = std::set_intersection(in1, in1, in2, in2, out, comp); @@ -782,13 +746,12 @@ main() binary_predicate_archetype comp(dummy_cons); std::inplace_merge(bi, bi, bi, comp); } + // gcc bug { -#if defined(__GNUC__) || defined(__KCC) typedef less_than_op_first_archetype< less_than_op_second_archetype, optag1>, optag2> Tin1; typedef less_than_op_second_archetype< less_than_op_first_archetype, optag1>, optag2> Tin2; -#endif input_iterator_archetype in1; input_iterator_archetype in2; bool b = std::includes(in1, in1, in2, in2); @@ -796,17 +759,10 @@ main() ignore_unused_variable_warning(b); } { - typedef null_archetype Arg1; - typedef null_archetype Arg2; -#if defined(__GNUC__) || defined(__KCC) - typedef convertible_to_archetype > Tin1; - typedef convertible_to_archetype > Tin2; -#endif - input_iterator_archetype in1; - input_iterator_archetype in2; - binary_predicate_archetype comp(dummy_cons); + typedef null_archetype Tin; + input_iterator_archetype in1; + input_iterator_archetype in2; + binary_predicate_archetype comp(dummy_cons); bool b = std::includes(in1, in1, in2, in2, comp); b = std::lexicographical_compare(in1, in1, in2, in2, comp); ignore_unused_variable_warning(b); @@ -897,8 +853,7 @@ main() typedef sgi_assignable_archetype< convertible_to_archetype > T; typedef convertible_to_archetype Ret; - typedef convertible_to_archetype Tin; - input_iterator_archetype in; + input_iterator_archetype in; T init(dummy_cons); binary_function_archetype op(dummy_cons); init = std::accumulate(in, in, init, op); @@ -918,38 +873,30 @@ main() convertible_to_archetype > T; typedef convertible_to_archetype RetMult; typedef convertible_to_archetype RetAdd; - typedef convertible_to_archetype Tin1; - typedef convertible_to_archetype Tin2; - input_iterator_archetype in1; - input_iterator_archetype in2; + input_iterator_archetype in1; + input_iterator_archetype in2; T init(dummy_cons); binary_function_archetype mult_op(dummy_cons); binary_function_archetype add_op(dummy_cons); init = std::inner_product(in1, in1, in2, init, add_op, mult_op); } { - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); + input_iterator_archetype in; + output_iterator_archetype out(dummy_cons); out = std::partial_sum(in, in, out); } { - typedef null_archetype Arg; - typedef null_archetype Tout; - typedef sgi_assignable_archetype< - convertible_to_archetype > > Tin; - typedef convertible_to_archetype > Ret; - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); - binary_function_archetype add_op(dummy_cons); + typedef sgi_assignable_archetype<> T; + input_iterator_archetype in; + output_iterator_archetype out(dummy_cons); + binary_function_archetype add_op(dummy_cons); out = std::partial_sum(in, in, out, add_op); - binary_function_archetype subtract_op(dummy_cons); + binary_function_archetype subtract_op(dummy_cons); out = std::adjacent_difference(in, in, out, subtract_op); } { - input_iterator_archetype in; - output_iterator_archetype out(dummy_cons); + input_iterator_archetype in; + output_iterator_archetype out(dummy_cons); out = std::adjacent_difference(in, in, out); } return 0;