diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/concept_check/test | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/concept_check/test')
16 files changed, 1592 insertions, 0 deletions
diff --git a/src/boost/libs/concept_check/test/Jamfile.v2 b/src/boost/libs/concept_check/test/Jamfile.v2 new file mode 100644 index 000000000..4510302b7 --- /dev/null +++ b/src/boost/libs/concept_check/test/Jamfile.v2 @@ -0,0 +1,25 @@ +# Copyright David Abrahams, Jeremy Siek, Vladimir Prus +# 2006. Distributed under the Boost Software License, Version +# 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +import testing ; + +test-suite concept_check + : [ link stl_concept_covering.cpp ] + [ run stl_concept_check.cpp ] + [ run concept_check_test.cpp ] + [ run class_concept_check_test.cpp ] + [ compile-fail concept_check_fail_expected.cpp ] + [ compile-fail class_concept_fail_expected.cpp ] + + [ run where.cpp ] + [ compile-fail where_fail.cpp ] + [ compile-fail usage_fail.cpp ] + + # Backward compatibility tests + [ run old_concept_pass.cpp ] + [ compile-fail function_requires_fail.cpp ] + [ compile-fail old_concept_function_fail.cpp ] + [ compile-fail old_concept_class_fail.cpp ] + ; + diff --git a/src/boost/libs/concept_check/test/class_concept_check_test.cpp b/src/boost/libs/concept_check/test/class_concept_check_test.cpp new file mode 100644 index 000000000..d5512c64f --- /dev/null +++ b/src/boost/libs/concept_check/test/class_concept_check_test.cpp @@ -0,0 +1,34 @@ +// (C) Copyright Jeremy Siek 2000. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/concept_check.hpp> + +/* + + This file verifies that the BOOST_CLASS_REQUIRE macro of the Boost + Concept Checking Library does not cause errors when it is not suppose + to. + +*/ + +struct foo { bool operator()(int) { return true; } }; +struct bar { bool operator()(int, char) { return true; } }; + +class class_requires_test +{ + BOOST_CONCEPT_ASSERT((boost::EqualityComparable<int>)); + typedef int* int_ptr; typedef const int* const_int_ptr; + BOOST_CONCEPT_ASSERT((boost::EqualOp<int_ptr,const_int_ptr>)); + BOOST_CONCEPT_ASSERT((boost::UnaryFunction<foo,bool,int>)); + BOOST_CONCEPT_ASSERT((boost::BinaryFunction<bar,bool,int,char>)); +}; + +int +main() +{ + class_requires_test x; + boost::ignore_unused_variable_warning(x); + return 0; +} diff --git a/src/boost/libs/concept_check/test/class_concept_fail_expected.cpp b/src/boost/libs/concept_check/test/class_concept_fail_expected.cpp new file mode 100644 index 000000000..74268e36e --- /dev/null +++ b/src/boost/libs/concept_check/test/class_concept_fail_expected.cpp @@ -0,0 +1,32 @@ +// (C) Copyright Jeremy Siek, David Abrahams 2000-2006. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Change Log: +// 20 Jan 2001 - Added warning suppression (David Abrahams) + +#include <boost/concept_check.hpp> + +/* + + This file verifies that class_requires of the Boost Concept Checking + Library catches errors when it is supposed to. + +*/ + +struct foo { }; + +template <class T> +class class_requires_test +{ + BOOST_CONCEPT_ASSERT((boost::EqualityComparable<foo>)); +}; + +int +main() +{ + class_requires_test<int> x; + (void)x; // suppress unused variable warning + return 0; +} diff --git a/src/boost/libs/concept_check/test/concept_check_fail_expected.cpp b/src/boost/libs/concept_check/test/concept_check_fail_expected.cpp new file mode 100644 index 000000000..15bfe7a82 --- /dev/null +++ b/src/boost/libs/concept_check/test/concept_check_fail_expected.cpp @@ -0,0 +1,26 @@ +// (C) Copyright Jeremy Siek, David Abrahams 2000-2006. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifdef NDEBUG +# undef NDEBUG +#endif + +#include <boost/concept_check.hpp> + +/* + + This file verifies that BOOST_CONCEPT_ASSERT catches errors in + function context. + +*/ + +struct foo { }; + +int +main() +{ + BOOST_CONCEPT_ASSERT((boost::EqualityComparable<foo>)); + return 0; +} diff --git a/src/boost/libs/concept_check/test/concept_check_test.cpp b/src/boost/libs/concept_check/test/concept_check_test.cpp new file mode 100644 index 000000000..f39ced781 --- /dev/null +++ b/src/boost/libs/concept_check/test/concept_check_test.cpp @@ -0,0 +1,177 @@ +// (C) Copyright Jeremy Siek 2000. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/concept_check.hpp> +#include <boost/concept_archetype.hpp> + +/* + + This file verifies that function_requires() of the Boost Concept + Checking Library does not cause errors when it is not suppose to + and verifies that the concept archetypes meet the requirements of + their matching concepts. + +*/ + + +int +main() +{ + using namespace boost; + + //=========================================================================== + // Basic Concepts + { + typedef default_constructible_archetype<> foo; + function_requires< DefaultConstructible<foo> >(); + } + { + typedef assignable_archetype<> foo; + function_requires< Assignable<foo> >(); + } + { + typedef copy_constructible_archetype<> foo; + function_requires< CopyConstructible<foo> >(); + } + { + typedef sgi_assignable_archetype<> foo; + function_requires< SGIAssignable<foo> >(); + } + { + typedef copy_constructible_archetype<> foo; + typedef convertible_to_archetype<foo> convertible_to_foo; + function_requires< Convertible<convertible_to_foo, foo> >(); + } + { + function_requires< Convertible<boolean_archetype, bool> >(); + } + { + typedef equality_comparable_archetype<> foo; + function_requires< EqualityComparable<foo> >(); + } + { + typedef less_than_comparable_archetype<> foo; + function_requires< LessThanComparable<foo> >(); + } + { + typedef comparable_archetype<> foo; + function_requires< Comparable<foo> >(); + } + { + typedef equal_op_first_archetype<> First; + typedef equal_op_second_archetype<> Second; + function_requires< EqualOp<First, Second> >(); + } + { + typedef not_equal_op_first_archetype<> First; + typedef not_equal_op_second_archetype<> Second; + function_requires< NotEqualOp<First, Second> >(); + } + { + typedef less_than_op_first_archetype<> First; + typedef less_than_op_second_archetype<> Second; + function_requires< LessThanOp<First, Second> >(); + } + { + typedef less_equal_op_first_archetype<> First; + typedef less_equal_op_second_archetype<> Second; + function_requires< LessEqualOp<First, Second> >(); + } + { + typedef greater_than_op_first_archetype<> First; + typedef greater_than_op_second_archetype<> Second; + function_requires< GreaterThanOp<First, Second> >(); + } + { + typedef greater_equal_op_first_archetype<> First; + typedef greater_equal_op_second_archetype<> Second; + function_requires< GreaterEqualOp<First, Second> >(); + } + + { + typedef copy_constructible_archetype<> Return; + typedef plus_op_first_archetype<Return> First; + typedef plus_op_second_archetype<Return> Second; + function_requires< PlusOp<Return, First, Second> >(); + } + + //=========================================================================== + // Function Object Concepts + + { + typedef generator_archetype<null_archetype<> > foo; + function_requires< Generator<foo, null_archetype<> > >(); + } +#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + { + function_requires< Generator< void_generator_archetype, void > >(); + } +#endif + { + typedef unary_function_archetype<int, int> F; + function_requires< UnaryFunction<F, int, int> >(); + } + { + typedef binary_function_archetype<int, int, int> F; + function_requires< BinaryFunction<F, int, int, int> >(); + } + { + typedef unary_predicate_archetype<int> F; + function_requires< UnaryPredicate<F, int> >(); + } + { + typedef binary_predicate_archetype<int, int> F; + function_requires< BinaryPredicate<F, int, int> >(); + } + + //=========================================================================== + // Iterator Concepts + { + typedef input_iterator_archetype<null_archetype<> > Iter; + function_requires< InputIterator<Iter> >(); + } + { + typedef output_iterator_archetype<int> Iter; + function_requires< OutputIterator<Iter, int> >(); + } + { + typedef input_output_iterator_archetype<int> Iter; + function_requires< InputIterator<Iter> >(); + function_requires< OutputIterator<Iter, int> >(); + } + { + typedef forward_iterator_archetype<null_archetype<> > Iter; + function_requires< ForwardIterator<Iter> >(); + } + { + typedef mutable_forward_iterator_archetype<assignable_archetype<> > Iter; + function_requires< Mutable_ForwardIterator<Iter> >(); + } + { + typedef bidirectional_iterator_archetype<null_archetype<> > Iter; + function_requires< BidirectionalIterator<Iter> >(); + } + { + typedef mutable_bidirectional_iterator_archetype<assignable_archetype<> > + Iter; + function_requires< Mutable_BidirectionalIterator<Iter> >(); + } + { + typedef random_access_iterator_archetype<null_archetype<> > Iter; + function_requires< RandomAccessIterator<Iter> >(); + } + { + typedef mutable_random_access_iterator_archetype<assignable_archetype<> > + Iter; + function_requires< Mutable_RandomAccessIterator<Iter> >(); + } + + //=========================================================================== + // Container Concepts + + // UNDER CONSTRUCTION + + return 0; +} diff --git a/src/boost/libs/concept_check/test/fake_sort.hpp b/src/boost/libs/concept_check/test/fake_sort.hpp new file mode 100644 index 000000000..99c75465a --- /dev/null +++ b/src/boost/libs/concept_check/test/fake_sort.hpp @@ -0,0 +1,27 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_LIBS_CONCEPT_CHECK_FAKE_SORT_DWA2006430_HPP +# define BOOST_LIBS_CONCEPT_CHECK_FAKE_SORT_DWA2006430_HPP + +# include <boost/detail/iterator.hpp> +# include <boost/concept/requires.hpp> +# include <boost/concept_check.hpp> + +namespace fake +{ + using namespace boost; + + template<typename RanIter> + BOOST_CONCEPT_REQUIRES( + ((Mutable_RandomAccessIterator<RanIter>)) + ((LessThanComparable<typename Mutable_RandomAccessIterator<RanIter>::value_type>)) + + , (void)) + sort(RanIter,RanIter) + { + + } +} + +#endif // BOOST_LIBS_CONCEPT_CHECK_FAKE_SORT_DWA2006430_HPP diff --git a/src/boost/libs/concept_check/test/function_requires_fail.cpp b/src/boost/libs/concept_check/test/function_requires_fail.cpp new file mode 100644 index 000000000..03beaecc8 --- /dev/null +++ b/src/boost/libs/concept_check/test/function_requires_fail.cpp @@ -0,0 +1,26 @@ +// (C) Copyright Jeremy Siek 2000. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifdef NDEBUG +# undef NDEBUG +#endif + +#include <boost/concept_check.hpp> + +/* + + This file verifies that function_requires() of the Boost Concept + Checking Library catches errors when it is suppose to. + +*/ + +struct foo { }; + +int +main() +{ + boost::function_requires< boost::EqualityComparable<foo> >(); + return 0; +} diff --git a/src/boost/libs/concept_check/test/old_concept_class_fail.cpp b/src/boost/libs/concept_check/test/old_concept_class_fail.cpp new file mode 100644 index 000000000..be41037fa --- /dev/null +++ b/src/boost/libs/concept_check/test/old_concept_class_fail.cpp @@ -0,0 +1,28 @@ +// (C) Copyright Jeremy Siek, David Abrahams 2000-2006. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Change Log: +// 20 Jan 2001 - Added warning suppression (David Abrahams) + +#include "old_concepts.hpp" + +// This file verifies that concepts written the old way still catch +// errors in class context. This is not expected to work on compilers +// without SFINAE support. + +struct foo { }; + +class class_requires_test +{ + BOOST_CLASS_REQUIRE(foo, old, EqualityComparableConcept); +}; + +int +main() +{ + class_requires_test x; + (void)x; // suppress unused variable warning + return 0; +} diff --git a/src/boost/libs/concept_check/test/old_concept_function_fail.cpp b/src/boost/libs/concept_check/test/old_concept_function_fail.cpp new file mode 100644 index 000000000..6b7bf30a3 --- /dev/null +++ b/src/boost/libs/concept_check/test/old_concept_function_fail.cpp @@ -0,0 +1,23 @@ +// (C) Copyright Jeremy Siek 2000. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifdef NDEBUG +# undef NDEBUG +#endif + +#include "old_concepts.hpp" + +// This file verifies that concepts written the old way still catch +// errors in function context. This is not expected to work on +// compilers without SFINAE support. + +struct foo { }; + +int +main() +{ + boost::function_requires< old::EqualityComparableConcept<foo> >(); + return 0; +} diff --git a/src/boost/libs/concept_check/test/old_concept_pass.cpp b/src/boost/libs/concept_check/test/old_concept_pass.cpp new file mode 100644 index 000000000..e9601fc24 --- /dev/null +++ b/src/boost/libs/concept_check/test/old_concept_pass.cpp @@ -0,0 +1,34 @@ +// (C) Copyright Jeremy Siek, David Abrahams 2000-2006. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/concept_check.hpp> +#include "old_concepts.hpp" + +// This test verifies that use of the old-style concept checking +// classes still compiles (but not that it detects constraint +// violations). We check them with the old-style macros just for +// completeness, since those macros stranslate into +// BOOST_CONCEPT_ASSERTs. + +struct foo { bool operator()(int) { return true; } }; +struct bar { bool operator()(int, char) { return true; } }; + + +class class_requires_test +{ + BOOST_CLASS_REQUIRE(int, old, EqualityComparableConcept); + typedef int* int_ptr; typedef const int* const_int_ptr; + BOOST_CLASS_REQUIRE2(int_ptr, const_int_ptr, old, EqualOpConcept); + BOOST_CLASS_REQUIRE3(foo, bool, int, old, UnaryFunctionConcept); + BOOST_CLASS_REQUIRE4(bar, bool, int, char, old, BinaryFunctionConcept); +}; + +int +main() +{ + class_requires_test x; + boost::ignore_unused_variable_warning(x); + return 0; +} diff --git a/src/boost/libs/concept_check/test/old_concepts.hpp b/src/boost/libs/concept_check/test/old_concepts.hpp new file mode 100644 index 000000000..76fad3c64 --- /dev/null +++ b/src/boost/libs/concept_check/test/old_concepts.hpp @@ -0,0 +1,67 @@ +// Copyright Jeremy Siek, David Abrahams 2000-2006. Distributed under +// the Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_LIBS_CONCEPT_CHECK_OLD_CONCEPTS_DWA2006428_HPP +# define BOOST_LIBS_CONCEPT_CHECK_OLD_CONCEPTS_DWA2006428_HPP + +#include <boost/concept_check.hpp> + +namespace old +{ + template <class TT> + void require_boolean_expr(const TT& t) { + bool x = t; + boost::ignore_unused_variable_warning(x); + } + + template <class TT> + struct EqualityComparableConcept + { + void constraints() { + boost::require_boolean_expr(a == b); + boost::require_boolean_expr(a != b); + } + TT a, b; + }; + + template <class Func, class Return, class Arg> + struct UnaryFunctionConcept + { + // required in case any of our template args are const-qualified: + UnaryFunctionConcept(); + + void constraints() { + r = f(arg); // require operator() + } + Func f; + Arg arg; + Return r; + }; + + template <class Func, class Return, class First, class Second> + struct BinaryFunctionConcept + { + void constraints() { + r = f(first, second); // require operator() + } + Func f; + First first; + Second second; + Return r; + }; + +#define DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(OP,NAME) \ + template <class First, class Second> \ + struct NAME { \ + void constraints() { (void)constraints_(); } \ + bool constraints_() { \ + return a OP b; \ + } \ + First a; \ + Second b; \ + } + + DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, EqualOpConcept); +} + +#endif // BOOST_LIBS_CONCEPT_CHECK_OLD_CONCEPTS_DWA2006428_HPP diff --git a/src/boost/libs/concept_check/test/stl_concept_check.cpp b/src/boost/libs/concept_check/test/stl_concept_check.cpp new file mode 100644 index 000000000..d336de1c0 --- /dev/null +++ b/src/boost/libs/concept_check/test/stl_concept_check.cpp @@ -0,0 +1,93 @@ +// (C) Copyright Jeremy Siek 2000. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// +// This file checks to see if various standard container +// implementations live up to requirements specified in the C++ +// standard. As many implementations do not live to the requirements, +// it is not uncommon for this file to fail to compile. The +// BOOST_HIDE_EXPECTED_ERRORS macro is provided here if you want to +// see as much of this file compile as possible. +// + +#include <boost/concept_check.hpp> + +#include <iterator> +#include <set> +#include <map> +#include <vector> +#include <list> +#include <deque> +#if 0 +#include <slist> +#endif + +// Define this macro if you want to hide the expected error, that is, +// error in the various C++ standard library implementations. +// +//#define BOOST_HIDE_EXPECTED_ERRORS + +int +main() +{ + using namespace boost; + +#if defined(_ITERATOR_) && defined(BOOST_HIDE_EXPECTED_ERRORS) + // VC++ STL implementation is not standard conformant and + // fails to pass these concept checks +#else + typedef std::vector<int> Vector; + typedef std::deque<int> Deque; + typedef std::list<int> List; + + // VC++ missing pointer and const_pointer typedefs + function_requires< Mutable_RandomAccessContainer<Vector> >(); + function_requires< BackInsertionSequence<Vector> >(); + +#if !(defined(__GNUC__) && defined(BOOST_HIDE_EXPECTED_ERRORS)) +#if !((defined(__sgi) || (defined(__DECCXX) && defined(_RWSTD_VER) && _RWSTD_VER <= 0x0203)) \ + && defined(BOOST_HIDE_EXPECTED_ERRORS)) + // old deque iterator missing n + iter operation + function_requires< Mutable_RandomAccessContainer<Deque> >(); +#endif + // warnings about signed and unsigned in old deque version + function_requires< FrontInsertionSequence<Deque> >(); + function_requires< BackInsertionSequence<Deque> >(); +#endif + + // VC++ missing pointer and const_pointer typedefs + function_requires< Mutable_ReversibleContainer<List> >(); + function_requires< FrontInsertionSequence<List> >(); + function_requires< BackInsertionSequence<List> >(); + +#if 0 + typedef BOOST_STD_EXTENSION_NAMESPACE::slist<int> SList; + function_requires< FrontInsertionSequence<SList> >(); +#endif + + typedef std::set<int> Set; + typedef std::multiset<int> MultiSet; + typedef std::map<int,int> Map; + typedef std::multimap<int,int> MultiMap; + + function_requires< SortedAssociativeContainer<Set> >(); + function_requires< SimpleAssociativeContainer<Set> >(); + function_requires< UniqueAssociativeContainer<Set> >(); + + function_requires< SortedAssociativeContainer<MultiSet> >(); + function_requires< SimpleAssociativeContainer<MultiSet> >(); + function_requires< MultipleAssociativeContainer<MultiSet> >(); + + function_requires< SortedAssociativeContainer<Map> >(); + function_requires< UniqueAssociativeContainer<Map> >(); + function_requires< PairAssociativeContainer<Map> >(); + + function_requires< SortedAssociativeContainer<MultiMap> >(); + function_requires< MultipleAssociativeContainer<MultiMap> >(); + function_requires< PairAssociativeContainer<MultiMap> >(); +#endif + + return 0; +} diff --git a/src/boost/libs/concept_check/test/stl_concept_covering.cpp b/src/boost/libs/concept_check/test/stl_concept_covering.cpp new file mode 100644 index 000000000..220294276 --- /dev/null +++ b/src/boost/libs/concept_check/test/stl_concept_covering.cpp @@ -0,0 +1,950 @@ +// (C) Copyright Jeremy Siek 2000-2002. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <algorithm> +#include <numeric> +#include <boost/config.hpp> +#include <boost/concept_check.hpp> +#include <boost/concept_archetype.hpp> + +/* + + This file uses the archetype classes to find out which concepts + actually *cover* the STL algorithms true requirements. The + archetypes/concepts chosen do not necessarily match the C++ standard + or the SGI STL documentation, but instead were chosen based on the + minimal concepts that current STL implementations require, which in + many cases is less stringent than the standard. In some places there + was significant differences in the implementations' requirements and + in those places macros were used to select different requirements, + the purpose being to document what the requirements of various + implementations are. It is an open issue as to whether the C++ + standard should be changed to reflect these weaker requirements. + +*/ + +/** + * Input iterator - explanation from Peter Dimov: + * + * Requirements say that *it is convertible to the value_type, and it is, in + * our case. The problem however is that op== is a template and the first + * argument fails deduction. std::find is specified in terms of the exact + * expression `*it == value`, so if it doesn't compile (and it doesn't), + * `find(it, it, value)` won't compile either. + * + * To address this, the no_proxy variant of the input iterator is used + * instead. + */ + +#define BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE input_iterator_archetype_no_proxy + +boost::detail::dummy_constructor dummy_cons; + +// This is a special concept needed for std::swap_ranges. +// It is mutually convertible, and also SGIAssignable +template <class T> +class mutually_convertible_archetype +{ +private: + mutually_convertible_archetype() { } +public: + mutually_convertible_archetype(const mutually_convertible_archetype&) { } + mutually_convertible_archetype& + operator=(const mutually_convertible_archetype&) + { return *this; } + mutually_convertible_archetype(boost::detail::dummy_constructor) { } + + template <class U> + mutually_convertible_archetype& + operator=(const mutually_convertible_archetype<U>&) + { return *this; } + +}; + + +// for std::accumulate +namespace accum +{ + typedef boost::sgi_assignable_archetype<> Ret; + struct T { + T(const Ret&) { } + T(boost::detail::dummy_constructor x) { } + }; + typedef boost::null_archetype<> Tin; + Ret operator+(const T&, const Tin&) { + return Ret(dummy_cons); + } +} + +// for std::shuffle +namespace shuffle +{ + struct URBG { + typedef unsigned int result_type; + result_type BOOST_CONSTEXPR static min() { return 0; } + result_type BOOST_CONSTEXPR static max() { return 1; } + result_type operator()() { return 1; } + }; +} + +// for std::inner_product +namespace inner_prod +{ + typedef boost::sgi_assignable_archetype<> RetAdd; + typedef boost::sgi_assignable_archetype<> RetMult; + struct T { + T(const RetAdd&) { } + T(boost::detail::dummy_constructor x) { } + }; + typedef boost::null_archetype<int> Tin1; + typedef boost::null_archetype<char> Tin2; +} + +namespace boost { // so Koenig lookup will find + + inner_prod::RetMult + operator*(const inner_prod::Tin1&, const inner_prod::Tin2&) { + return inner_prod::RetMult(dummy_cons); + } + inner_prod::RetAdd + operator+(const inner_prod::T&, + const inner_prod::RetMult&) { + return inner_prod::RetAdd(dummy_cons); + } +} + + +// for std::partial_sum and adj_diff +namespace part_sum +{ + class T { + public: + typedef boost::sgi_assignable_archetype<> Ret; + T(const Ret&) { } + T(boost::detail::dummy_constructor x) { } + private: + T() { } + }; + T::Ret operator+(const T&, const T&) { + return T::Ret(dummy_cons); + } + T::Ret operator-(const T&, const T&) { + return T::Ret(dummy_cons); + } +} + +// for std::power + +namespace power_stuff { + struct monoid_archetype { + monoid_archetype(boost::detail::dummy_constructor x) { } + }; + + boost::multipliable_archetype<monoid_archetype> + identity_element + (std::multiplies< boost::multipliable_archetype<monoid_archetype> >) + { + return boost::multipliable_archetype<monoid_archetype>(dummy_cons); + } +} + +struct tag1 { }; +struct tag2 { }; + + +int +main() +{ + using namespace boost; + + //=========================================================================== + // Non-mutating Algorithms + { + 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; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE< Left > in; + equality_comparable2_second_archetype<> value(dummy_cons); + in = std::find(in, in, value); + } + { + typedef null_archetype<> T; + input_iterator_archetype<T> in; + unary_predicate_archetype<T> pred(dummy_cons); + in = std::find_if(in, in, pred); + } + { + forward_iterator_archetype< equality_comparable_archetype<> > fo; + fo = std::adjacent_find(fo, fo); + } + { + forward_iterator_archetype< + convertible_to_archetype< null_archetype<> > > fo; + binary_predicate_archetype<null_archetype<> , null_archetype<> > + pred(dummy_cons); + fo = std::adjacent_find(fo, fo, pred); + } + // gcc bug + { + typedef equal_op_first_archetype<> Left; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Left> in; + typedef equal_op_second_archetype<> Right; + forward_iterator_archetype<Right> fo; + in = std::find_first_of(in, in, fo, fo); + } + { + typedef equal_op_first_archetype<> Left; + typedef BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Left> InIter; + InIter in; + function_requires< InputIterator<InIter> >(); + equal_op_second_archetype<> value(dummy_cons); + std::iterator_traits<InIter>::difference_type + n = std::count(in, in, value); + ignore_unused_variable_warning(n); + } + { + typedef input_iterator_archetype< null_archetype<> > InIter; + InIter in; + unary_predicate_archetype<null_archetype<> > pred(dummy_cons); + std::iterator_traits<InIter>::difference_type + n = std::count_if(in, in, pred); + ignore_unused_variable_warning(n); + } + // gcc bug + { + typedef equal_op_first_archetype<> Left; + typedef BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Left> InIter1; + InIter1 in1; + typedef equal_op_second_archetype<> Right; + typedef BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Right> InIter2; + InIter2 in2; + std::pair<InIter1, InIter2> p = std::mismatch(in1, in1, in2); + ignore_unused_variable_warning(p); + } + { + typedef input_iterator_archetype<null_archetype<> > InIter; + InIter in1, in2; + binary_predicate_archetype<null_archetype<> , null_archetype<> > + pred(dummy_cons); + std::pair<InIter, InIter> p = std::mismatch(in1, in1, in2, pred); + ignore_unused_variable_warning(p); + } + // gcc bug + { + typedef equality_comparable2_first_archetype<> Left; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Left> in1; + typedef equality_comparable2_second_archetype<> Right; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Right> in2; + bool b = std::equal(in1, in1, in2); + ignore_unused_variable_warning(b); + } + { + input_iterator_archetype< null_archetype<> > + in1, in2; + binary_predicate_archetype<null_archetype<> , null_archetype<> > + pred(dummy_cons); + bool b = std::equal(in1, in1, in2, pred); + ignore_unused_variable_warning(b); + } + { + typedef equality_comparable2_first_archetype<> Left; + forward_iterator_archetype<Left> fo1; + typedef equality_comparable2_second_archetype<> Right; + forward_iterator_archetype<Right> fo2; + fo1 = std::search(fo1, fo1, fo2, fo2); + } + { + typedef equality_comparable2_first_archetype< + convertible_to_archetype<null_archetype<> > > Left; + forward_iterator_archetype<Left> fo1; + typedef equality_comparable2_second_archetype< + convertible_to_archetype<null_archetype<> > > Right; + forward_iterator_archetype<Right> fo2; + binary_predicate_archetype<null_archetype<> , null_archetype<> > + pred(dummy_cons); + fo1 = std::search(fo1, fo1, fo2, fo2, pred); + } + { + typedef equality_comparable2_first_archetype<> Left; + forward_iterator_archetype<Left> fo; + equality_comparable2_second_archetype<> value(dummy_cons); + int n = 1; + fo = std::search_n(fo, fo, n, value); + } + { + forward_iterator_archetype< + convertible_to_archetype<null_archetype<> > > fo; + convertible_to_archetype<null_archetype<> > value(dummy_cons); + binary_predicate_archetype<null_archetype<> , null_archetype<> > + pred(dummy_cons); + int n = 1; + fo = std::search_n(fo, fo, n, value, pred); + } + { + typedef equality_comparable2_first_archetype<> Left; + forward_iterator_archetype<Left> fo1; + typedef equality_comparable2_second_archetype<null_archetype<> > Right; + forward_iterator_archetype<Right> fo2; + fo1 = std::find_end(fo1, fo1, fo2, fo2); + } + { + // equality comparable required because find_end() calls search + typedef equality_comparable2_first_archetype< + convertible_to_archetype<null_archetype<> > > Left; + forward_iterator_archetype<Left> fo1; + typedef equality_comparable2_second_archetype< + convertible_to_archetype<null_archetype<> > > Right; + forward_iterator_archetype<Right> fo2; + binary_predicate_archetype<null_archetype<> , null_archetype<> > + pred(dummy_cons); + fo1 = std::find_end(fo1, fo1, fo2, fo2, pred); + } + + //=========================================================================== + // Mutating Algorithms + + { + typedef null_archetype<> T; + input_iterator_archetype<T> in; + output_iterator_archetype<T> out(dummy_cons); + out = std::copy(in, in, out); + } + { + typedef assignable_archetype<> OutT; + typedef convertible_to_archetype<OutT> InT; + bidirectional_iterator_archetype<InT> bid_in; + mutable_bidirectional_iterator_archetype<OutT> bid_out; + bid_out = std::copy_backward(bid_in, bid_in, bid_out); + } + { + sgi_assignable_archetype<> a(dummy_cons), b(dummy_cons); + std::swap(a, b); + } + { + typedef sgi_assignable_archetype<> T; + mutable_forward_iterator_archetype<T> a, b; + std::iter_swap(a, b); + } +#if 0 + { + // fails on gcc 7.3 and clang 6.0 + typedef mutually_convertible_archetype<int> Tin; + typedef mutually_convertible_archetype<char> Tout; + mutable_forward_iterator_archetype<Tin> fi1; + mutable_forward_iterator_archetype<Tout> fi2; + fi2 = std::swap_ranges(fi1, fi1, fi2); + } +#endif + { + typedef null_archetype<int> Tin; + typedef null_archetype<char> Tout; + input_iterator_archetype<Tin> in; + output_iterator_archetype<Tout> out(dummy_cons); + unary_function_archetype<null_archetype<> , + convertible_to_archetype<Tout> > op(dummy_cons); + out = std::transform(in, in, out, op); + } + { + typedef null_archetype<int> Tin1; + typedef null_archetype<char> Tin2; + typedef null_archetype<double> Tout; + input_iterator_archetype<Tin1> in1; + input_iterator_archetype<Tin2> in2; + output_iterator_archetype<Tout> out(dummy_cons); + binary_function_archetype<Tin1, Tin2, + convertible_to_archetype<Tout> > op(dummy_cons); + out = std::transform(in1, in1, in2, out, op); + } + { + typedef equality_comparable2_first_archetype< + assignable_archetype<> > FT; + mutable_forward_iterator_archetype<FT> fi; + equality_comparable2_second_archetype< + convertible_to_archetype<FT> > value(dummy_cons); + std::replace(fi, fi, value, value); + } + { + typedef null_archetype<> PredArg; + typedef assignable_archetype< + convertible_to_archetype<PredArg> > FT; + mutable_forward_iterator_archetype<FT> fi; + unary_predicate_archetype<PredArg> pred(dummy_cons); + convertible_to_archetype<FT> value(dummy_cons); + std::replace_if(fi, fi, pred, value); + } +#if !defined(BOOST_MSVC) || BOOST_WORKAROUND(BOOST_MSVC, > 1900) + // fails on MSVC 2015 and earlier + { + // Issue, the use of ?: inside replace_copy() complicates things + typedef equal_op_first_archetype<> Tin; + typedef null_archetype<> Tout; + typedef equal_op_second_archetype< convertible_to_archetype<Tout> > T; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin> in; + output_iterator_archetype<Tout> out(dummy_cons); + T value(dummy_cons); + out = std::replace_copy(in, in, out, value, value); + } + { + // The issue of ?: also affects this function + typedef null_archetype<> Tout; + typedef assignable_archetype< convertible_to_archetype<Tout> > Tin; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin> in; + output_iterator_archetype<Tout> out(dummy_cons); + unary_predicate_archetype<Tin> pred(dummy_cons); + Tin value(dummy_cons); + out = std::replace_copy_if(in, in, out, pred, value); + } +#endif + { + typedef assignable_archetype<> FT; + mutable_forward_iterator_archetype<FT> fi; + typedef convertible_to_archetype<FT> T; + T value(dummy_cons); + std::fill(fi, fi, value); + } +#if !defined(BOOST_MSVC) || BOOST_WORKAROUND(BOOST_MSVC, >= 1700) + // fails on MSVC 2010 + { + typedef null_archetype<> Tout; + typedef convertible_to_archetype<Tout> T; + output_iterator_archetype<Tout> out(dummy_cons); + T value(dummy_cons); + int n = 1; + out = std::fill_n(out, n, value); + } +#endif + { + typedef assignable_archetype<> FT; + typedef convertible_to_archetype<FT> Ret; + mutable_forward_iterator_archetype<FT> fi; + generator_archetype<Ret> gen; + std::generate(fi, fi, gen); + } + { + typedef assignable_archetype<> FT; + typedef convertible_to_archetype<FT> Ret; + mutable_forward_iterator_archetype<FT> fi; + generator_archetype<Ret> gen; + int n = 1; + std::generate_n(fi, n, gen); + } + { + typedef assignable_archetype< equality_comparable2_first_archetype<> > FT; + typedef equality_comparable2_second_archetype<> T; + mutable_forward_iterator_archetype<FT> fi; + T value(dummy_cons); + fi = std::remove(fi, fi, value); + } + { + typedef assignable_archetype<> FT; + mutable_forward_iterator_archetype<FT> fi; + typedef null_archetype<> PredArg; + unary_predicate_archetype<PredArg> pred(dummy_cons); + fi = std::remove_if(fi, fi, pred); + } + // gcc bug + { + typedef null_archetype<> Tout; + typedef equality_comparable2_first_archetype< + convertible_to_archetype<Tout> > Tin; + typedef equality_comparable2_second_archetype<> T; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin> in; + output_iterator_archetype<Tout> out(dummy_cons); + T value(dummy_cons); + out = std::remove_copy(in, in, out, value); + } + { + typedef null_archetype<> T; + input_iterator_archetype<T> in; + output_iterator_archetype<T> out(dummy_cons); + unary_predicate_archetype<T> pred(dummy_cons); + out = std::remove_copy_if(in, in, out, pred); + } + { + typedef sgi_assignable_archetype< equality_comparable_archetype<> > T; + mutable_forward_iterator_archetype<T> fi; + fi = std::unique(fi, fi); + } + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg1, + convertible_to_archetype<Arg2> > > FT; + mutable_forward_iterator_archetype<FT> fi; + binary_predicate_archetype<Arg1, Arg2> pred(dummy_cons); + fi = std::unique(fi, fi, pred); + } + // gcc bug + { + typedef equality_comparable_archetype< sgi_assignable_archetype<> > T; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<T> in; + output_iterator_archetype<T> out(dummy_cons); + out = std::unique_copy(in, in, out); + } + { + typedef sgi_assignable_archetype<> T; + input_iterator_archetype<T> in; + output_iterator_archetype<T> out(dummy_cons); + binary_predicate_archetype<T, T> pred(dummy_cons); + out = std::unique_copy(in, in, out, pred); + } + { + typedef sgi_assignable_archetype<> T; + mutable_bidirectional_iterator_archetype<T> bi; + std::reverse(bi, bi); + } + { + typedef null_archetype<> Tout; + typedef convertible_to_archetype<Tout> Tin; + bidirectional_iterator_archetype<Tin> bi; + output_iterator_archetype<Tout> out(dummy_cons); + out = std::reverse_copy(bi, bi, out); + } + { + typedef sgi_assignable_archetype<> T; + mutable_forward_iterator_archetype<T> fi; + // Issue, SGI STL is not have void return type, C++ standard does + std::rotate(fi, fi, fi); + } + { + typedef null_archetype<> Tout; + typedef convertible_to_archetype<Tout> FT; + forward_iterator_archetype<FT> fi; + output_iterator_archetype<Tout> out(dummy_cons); + out = std::rotate_copy(fi, fi, fi, out); + } +#ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE + { + typedef sgi_assignable_archetype<> T; + mutable_random_access_iterator_archetype<T> ri; + std::random_shuffle(ri, ri); + } + { + typedef sgi_assignable_archetype<> T; + mutable_random_access_iterator_archetype<T> ri; + unary_function_archetype<std::ptrdiff_t, std::ptrdiff_t> ran(dummy_cons); + std::random_shuffle(ri, ri, ran); + } +#else + { + typedef sgi_assignable_archetype<> T; + mutable_random_access_iterator_archetype<T> ri; + shuffle::URBG urbg; + std::shuffle(ri, ri, urbg); + } +#endif + { + typedef null_archetype<> PredArg; + typedef sgi_assignable_archetype<convertible_to_archetype<PredArg> > FT; + mutable_bidirectional_iterator_archetype<FT> bi; + unary_predicate_archetype<PredArg> pred(dummy_cons); + bi = std::partition(bi, bi, pred); + } +#ifndef BOOST_MSVC + { + // fails on MSVC + typedef null_archetype<> PredArg; + typedef sgi_assignable_archetype<convertible_to_archetype<PredArg> > FT; + mutable_forward_iterator_archetype<FT> fi; + unary_predicate_archetype<PredArg> pred(dummy_cons); + fi = std::stable_partition(fi, fi, pred); + } +#endif + //=========================================================================== + // Sorting Algorithms + { + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; + mutable_random_access_iterator_archetype<T> ri; + std::sort(ri, ri); + } + { + typedef null_archetype<> Arg; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg> > T; + mutable_random_access_iterator_archetype<T> ri; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + std::sort(ri, ri, comp); + } + { + typedef less_than_comparable_archetype< + sgi_assignable_archetype<> > ValueType; + mutable_random_access_iterator_archetype<ValueType> ri; + std::stable_sort(ri, ri); + } + { + typedef null_archetype<> Arg; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg> > ValueType; + mutable_random_access_iterator_archetype<ValueType> ri; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + std::stable_sort(ri, ri, comp); + } + { + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; + mutable_random_access_iterator_archetype<T> ri; + std::partial_sort(ri, ri, ri); + } + + { + typedef null_archetype<> Arg; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg> > T; + mutable_random_access_iterator_archetype<T> ri; + binary_predicate_archetype<Arg, Arg> 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. + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<T> in; + mutable_random_access_iterator_archetype<T> ri_out; + ri_out = std::partial_sort_copy(in, in , ri_out, ri_out); + } + { + typedef sgi_assignable_archetype<> T; + input_iterator_archetype<T> in; + mutable_random_access_iterator_archetype<T> ri_out; + binary_predicate_archetype<T, T> comp(dummy_cons); + ri_out = std::partial_sort_copy(in, in , ri_out, ri_out, comp); + } + { + typedef sgi_assignable_archetype< less_than_comparable_archetype<> > T; + mutable_random_access_iterator_archetype<T> ri; + std::nth_element(ri, ri, ri); + } + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg1, + convertible_to_archetype<Arg2> > > T; + mutable_random_access_iterator_archetype<T> ri; + binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons); + 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<> T; + typedef convertible_to_archetype<T> FT; +#else + typedef less_than_op_first_archetype<> FT; + typedef less_than_op_second_archetype<> T; +#endif + forward_iterator_archetype<FT> fi; + T value(dummy_cons); + fi = std::lower_bound(fi, fi, value); + } + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + typedef convertible_to_archetype<Arg1> FT; + typedef convertible_to_archetype<Arg2> T; + forward_iterator_archetype<FT> fi; + T value(dummy_cons); + binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons); + fi = std::lower_bound(fi, fi, value, comp); + } + { +#if defined(__KCC) + typedef less_than_comparable_archetype<> T; + typedef convertible_to_archetype<T> FT; +#else + // Note, order of T,FT is flipped from lower_bound + typedef less_than_op_second_archetype<> FT; + typedef less_than_op_first_archetype<> T; +#endif + forward_iterator_archetype<FT> fi; + T value(dummy_cons); + fi = std::upper_bound(fi, fi, value); + } + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + // Note, order of T,FT is flipped from lower_bound + typedef convertible_to_archetype<Arg1> T; + typedef convertible_to_archetype<Arg2> FT; + forward_iterator_archetype<FT> fi; + T value(dummy_cons); + binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons); + fi = std::upper_bound(fi, fi, value, comp); + } +#if !defined(BOOST_MSVC) || BOOST_WORKAROUND(BOOST_MSVC, >= 1900) + // Fails on MSVC 2013 and earlier + { +#if defined(__KCC) + typedef less_than_comparable_archetype<> T; + typedef convertible_to_archetype<T> FT; +#else + typedef less_than_op_first_archetype< + less_than_op_second_archetype< null_archetype<>, optag2>, optag1> FT; + typedef less_than_op_second_archetype< + less_than_op_first_archetype< null_archetype<>, optag2>, optag1> T; +#endif + typedef forward_iterator_archetype<FT> FIter; + FIter fi; + T value(dummy_cons); + std::pair<FIter,FIter> p = std::equal_range(fi, fi, value); + ignore_unused_variable_warning(p); + } +#endif + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + typedef convertible_to_archetype<Arg1, + convertible_to_archetype<Arg2> > FT; + typedef convertible_to_archetype<Arg2, + convertible_to_archetype<Arg1> > T; + typedef forward_iterator_archetype<FT> FIter; + FIter fi; + T value(dummy_cons); + binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons); + std::pair<FIter,FIter> p = std::equal_range(fi, fi, value, comp); + ignore_unused_variable_warning(p); + } + { +#if defined(__KCC) + typedef less_than_op_first_archetype< less_than_comparable_archetype<> > T; + typedef less_than_op_second_archetype< convertible_to_archetype<T> > FT; +#else + typedef less_than_op_first_archetype< + less_than_op_second_archetype<null_archetype<>, optag2>, optag1> FT; + typedef less_than_op_second_archetype< + less_than_op_first_archetype<null_archetype<>, optag2>, optag1> T; +#endif + forward_iterator_archetype<FT> fi; + T value(dummy_cons); + bool b = std::binary_search(fi, fi, value); + ignore_unused_variable_warning(b); + } + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + typedef convertible_to_archetype<Arg1, + convertible_to_archetype<Arg2> > FT; + typedef convertible_to_archetype<Arg2, + convertible_to_archetype<Arg1> > T; + typedef forward_iterator_archetype<FT> FIter; + FIter fi; + T value(dummy_cons); + binary_predicate_archetype<Arg1, Arg2> comp(dummy_cons); + bool b = std::binary_search(fi, fi, value, comp); + ignore_unused_variable_warning(b); + } + { + typedef null_archetype<> Tout; + typedef less_than_op_first_archetype< + less_than_op_second_archetype< + convertible_to_archetype<Tout>, optag2>, optag1 > Tin1; + typedef less_than_op_second_archetype< + less_than_op_first_archetype< + convertible_to_archetype<Tout>, optag2> ,optag1> Tin2; + // gcc bug + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin1> in1; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin2> in2; + output_iterator_archetype<Tout> out(dummy_cons); + out = std::merge(in1, in1, in2, in2, out); + out = std::set_union(in1, in1, in2, in2, out); + out = std::set_intersection(in1, in1, in2, in2, out); + out = std::set_difference(in1, in1, in2, in2, out); + out = std::set_symmetric_difference(in1, in1, in2, in2, out); + } + { + typedef null_archetype<> T; + input_iterator_archetype<T> in1; + input_iterator_archetype<T,2> in2; + output_iterator_archetype<T> out(dummy_cons); + binary_predicate_archetype<T, T> 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); + out = std::set_difference(in1, in1, in2, in2, out, comp); + out = std::set_symmetric_difference(in1, in1, in2, in2, out, comp); + } + { + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; + mutable_bidirectional_iterator_archetype<T> bi; + std::inplace_merge(bi, bi, bi); + } + { + typedef null_archetype<> Arg; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg> > T; + mutable_bidirectional_iterator_archetype<T> bi; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + std::inplace_merge(bi, bi, bi, comp); + } + // gcc bug + { + typedef less_than_op_first_archetype< + less_than_op_second_archetype<null_archetype<>, optag1>, optag2> Tin1; + typedef less_than_op_second_archetype< + less_than_op_first_archetype<null_archetype<>, optag1>, optag2> Tin2; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin1> in1; + BOOST_CONCEPT_CHECK_COMPATIBLE_INPUT_ITERATOR_ARCHETYPE<Tin2> in2; + bool b = std::includes(in1, in1, in2, in2); + b = std::lexicographical_compare(in1, in1, in2, in2); + ignore_unused_variable_warning(b); + } + { + typedef null_archetype<int> Tin; + input_iterator_archetype<Tin> in1; + input_iterator_archetype<Tin,1> in2; + binary_predicate_archetype<Tin, Tin> 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); + } + { + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; + mutable_random_access_iterator_archetype<T> ri; + std::push_heap(ri, ri); + std::pop_heap(ri, ri); + std::make_heap(ri, ri); + std::sort_heap(ri, ri); + } + { + typedef null_archetype<> Arg; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg> > T; + mutable_random_access_iterator_archetype<T> ri; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + std::push_heap(ri, ri, comp); + std::pop_heap(ri, ri, comp); + std::make_heap(ri, ri, comp); + std::sort_heap(ri, ri, comp); + } + { + typedef less_than_comparable_archetype<> T; + T a(dummy_cons), b(dummy_cons); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + const T& c = min BOOST_PREVENT_MACRO_SUBSTITUTION(a, b); + const T& d = max BOOST_PREVENT_MACRO_SUBSTITUTION(a, b); + ignore_unused_variable_warning(c); + ignore_unused_variable_warning(d); + } + { + typedef null_archetype<> Arg; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + typedef convertible_to_archetype<Arg> T; + T a(dummy_cons), b(dummy_cons); + BOOST_USING_STD_MIN(); + BOOST_USING_STD_MAX(); + const T& c = min BOOST_PREVENT_MACRO_SUBSTITUTION(a, b, comp); + const T& d = max BOOST_PREVENT_MACRO_SUBSTITUTION(a, b, comp); + ignore_unused_variable_warning(c); + ignore_unused_variable_warning(d); + } + { + typedef less_than_comparable_archetype<> T; + forward_iterator_archetype<T> fi; + fi = std::min_element(fi, fi); + fi = std::max_element(fi, fi); + } + { + typedef null_archetype<> Arg; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + typedef convertible_to_archetype<Arg> T; + forward_iterator_archetype<T> fi; + fi = std::min_element(fi, fi, comp); + fi = std::max_element(fi, fi, comp); + } + { + typedef sgi_assignable_archetype< + less_than_comparable_archetype<> > T; + mutable_bidirectional_iterator_archetype<T> bi; + bool b = std::next_permutation(bi, bi); + b = std::prev_permutation(bi, bi); + ignore_unused_variable_warning(b); + } + { + typedef null_archetype<> Arg; + binary_predicate_archetype<Arg, Arg> comp(dummy_cons); + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg> > T; + mutable_bidirectional_iterator_archetype<T> bi; + bool b = std::next_permutation(bi, bi, comp); + b = std::prev_permutation(bi, bi, comp); + ignore_unused_variable_warning(b); + } + //=========================================================================== + // Generalized Numeric Algorithms + + { + // Bummer, couldn't use plus_op because of a problem with + // mutually recursive types. + input_iterator_archetype<accum::Tin> in; + accum::T init(dummy_cons); + init = std::accumulate(in, in, init); + } + { + typedef null_archetype<int> Arg1; + typedef null_archetype<char> Arg2; + typedef sgi_assignable_archetype< + convertible_to_archetype<Arg1> > T; + typedef convertible_to_archetype<T> Ret; + input_iterator_archetype<Arg2> in; + T init(dummy_cons); + binary_function_archetype<Arg1, Arg2, Ret> op(dummy_cons); + init = std::accumulate(in, in, init, op); + } + { + input_iterator_archetype<inner_prod::Tin1> in1; + input_iterator_archetype<inner_prod::Tin2> in2; + inner_prod::T init(dummy_cons); + init = std::inner_product(in1, in1, in2, init); + } + { + typedef null_archetype<int> MultArg1; + typedef null_archetype<char> MultArg2; + typedef null_archetype<short> AddArg1; + typedef null_archetype<long> AddArg2; + typedef sgi_assignable_archetype< + convertible_to_archetype<AddArg1> > T; + typedef convertible_to_archetype<AddArg2> RetMult; + typedef convertible_to_archetype<T> RetAdd; + input_iterator_archetype<MultArg1> in1; + input_iterator_archetype<MultArg2> in2; + T init(dummy_cons); + binary_function_archetype<MultArg1, MultArg2, RetMult> mult_op(dummy_cons); + binary_function_archetype<AddArg1, AddArg2, RetAdd> add_op(dummy_cons); + init = std::inner_product(in1, in1, in2, init, add_op, mult_op); + } + { + input_iterator_archetype<part_sum::T> in; + output_iterator_archetype<part_sum::T> out(dummy_cons); + out = std::partial_sum(in, in, out); + } + { + typedef sgi_assignable_archetype<> T; + input_iterator_archetype<T> in; + output_iterator_archetype<T> out(dummy_cons); + binary_function_archetype<T, T, T> add_op(dummy_cons); + out = std::partial_sum(in, in, out, add_op); + binary_function_archetype<T, T, T> subtract_op(dummy_cons); + out = std::adjacent_difference(in, in, out, subtract_op); + } + { + input_iterator_archetype<part_sum::T> in; + output_iterator_archetype<part_sum::T> out(dummy_cons); + out = std::adjacent_difference(in, in, out); + } + return 0; +} diff --git a/src/boost/libs/concept_check/test/usage_fail.cpp b/src/boost/libs/concept_check/test/usage_fail.cpp new file mode 100644 index 000000000..39b1060ff --- /dev/null +++ b/src/boost/libs/concept_check/test/usage_fail.cpp @@ -0,0 +1,24 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include <boost/concept/usage.hpp> +#include <boost/core/ignore_unused.hpp> + +template <class T> +struct StringInitializable +{ + typedef int associated; + BOOST_CONCEPT_USAGE(StringInitializable) + { + T x = "foo"; + boost::ignore_unused(x); + } +}; + +// Test that accessing an associated type will actually exercise usage +// requirements +typedef StringInitializable<int>::associated tee; + + + diff --git a/src/boost/libs/concept_check/test/where.cpp b/src/boost/libs/concept_check/test/where.cpp new file mode 100644 index 000000000..dfbfd020f --- /dev/null +++ b/src/boost/libs/concept_check/test/where.cpp @@ -0,0 +1,13 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include <vector> +#undef NDEBUG +#include "fake_sort.hpp" + +int main() +{ + std::vector<int> v; + fake::sort(v.begin(), v.end()); + return 0; +} diff --git a/src/boost/libs/concept_check/test/where_fail.cpp b/src/boost/libs/concept_check/test/where_fail.cpp new file mode 100644 index 000000000..e56b40fed --- /dev/null +++ b/src/boost/libs/concept_check/test/where_fail.cpp @@ -0,0 +1,13 @@ +// Copyright David Abrahams 2006. Distributed under the Boost +// Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include <list> +#undef NDEBUG +#include "fake_sort.hpp" + +int main() +{ + std::list<int> v; + fake::sort(v.begin(), v.end()); + return 0; +} |