diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/range/test/test_function | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/range/test/test_function')
7 files changed, 244 insertions, 0 deletions
diff --git a/src/boost/libs/range/test/test_function/check_equal_fn.hpp b/src/boost/libs/range/test/test_function/check_equal_fn.hpp new file mode 100644 index 00000000..8da2ed83 --- /dev/null +++ b/src/boost/libs/range/test/test_function/check_equal_fn.hpp @@ -0,0 +1,49 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_FUNCTIONS_CHECK_EQUAL_FN_HPP_INCLUDED +#define BOOST_RANGE_TEST_FUNCTIONS_CHECK_EQUAL_FN_HPP_INCLUDED + +#include "counted_function.hpp" + +namespace boost +{ + namespace range_test_function + { + template< class Collection > + class check_equal_fn : private counted_function + { + typedef BOOST_DEDUCED_TYPENAME Collection::const_iterator iter_t; + public: + explicit check_equal_fn( const Collection& c ) + : m_it(boost::begin(c)), m_last(boost::end(c)) {} + + using counted_function::invocation_count; + + void operator()(int x) const + { + invoked(); + BOOST_CHECK( m_it != m_last ); + if (m_it != m_last) + { + BOOST_CHECK_EQUAL( *m_it, x ); + ++m_it; + } + } + + private: + mutable iter_t m_it; + iter_t m_last; + }; + + } // namespace range_test_function +} // namespace boost + +#endif // include guard diff --git a/src/boost/libs/range/test/test_function/counted_function.hpp b/src/boost/libs/range/test/test_function/counted_function.hpp new file mode 100644 index 00000000..4a74515c --- /dev/null +++ b/src/boost/libs/range/test/test_function/counted_function.hpp @@ -0,0 +1,40 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_FUNCTION_COUNTED_FUNCTION_HPP_INCLUDED +#define BOOST_RANGE_TEST_FUNCTION_COUNTED_FUNCTION_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + + class counted_function + { + public: + counted_function() : m_count(0u) {} + + void invoked() const + { + ++m_count; + } + + // Return the number of times that this function object + // has been invoked. + unsigned int invocation_count() const { return m_count; } + + private: + mutable unsigned int m_count; + }; + + } +} + +#endif // include guard diff --git a/src/boost/libs/range/test/test_function/equal_to_x.hpp b/src/boost/libs/range/test/test_function/equal_to_x.hpp new file mode 100644 index 00000000..14d00162 --- /dev/null +++ b/src/boost/libs/range/test/test_function/equal_to_x.hpp @@ -0,0 +1,33 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_EQUAL_TO_X_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_EQUAL_TO_X_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + template<class Arg> + struct equal_to_x + { + typedef bool result_type; + typedef Arg argument_type; + + explicit equal_to_x(Arg x) : m_x(x) {} + bool operator()(Arg x) const { return x == m_x; } + + private: + Arg m_x; + }; + } +} + +#endif // include guard diff --git a/src/boost/libs/range/test/test_function/false_predicate.hpp b/src/boost/libs/range/test/test_function/false_predicate.hpp new file mode 100644 index 00000000..533e83d5 --- /dev/null +++ b/src/boost/libs/range/test/test_function/false_predicate.hpp @@ -0,0 +1,29 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_FALSE_PREDICATE_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_FALSE_PREDICATE_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + struct false_predicate + { + typedef bool result_type; + + bool operator()() const { return false; } + template<class Arg> bool operator()(Arg) const { return false; } + template<class Arg1, class Arg2> bool operator()(Arg1,Arg2) const { return false; } + }; + } +} + +#endif // include guard diff --git a/src/boost/libs/range/test/test_function/greater_than_x.hpp b/src/boost/libs/range/test/test_function/greater_than_x.hpp new file mode 100644 index 00000000..032f594e --- /dev/null +++ b/src/boost/libs/range/test/test_function/greater_than_x.hpp @@ -0,0 +1,32 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_FUNCTION_GREATER_THAN_X_HPP_INCLUDED +#define BOOST_RANGE_TEST_FUNCTION_GREATER_THAN_X_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + template< class Number > + struct greater_than_x + { + typedef bool result_type; + typedef Number argument_type; + + explicit greater_than_x(Number x) : m_x(x) {} + bool operator()(Number x) const { return x > m_x; } + private: + Number m_x; + }; + } // namespace range_test_function +} // namespace boost + +#endif // include guard diff --git a/src/boost/libs/range/test/test_function/multiply_by_x.hpp b/src/boost/libs/range/test/test_function/multiply_by_x.hpp new file mode 100644 index 00000000..b343c61e --- /dev/null +++ b/src/boost/libs/range/test/test_function/multiply_by_x.hpp @@ -0,0 +1,32 @@ +// Boost.Range library +// +// Copyright Neil Groves 2009. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_MULTIPLY_BY_X_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_MULTIPLY_BY_X_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + template< class Arg > + struct multiply_by_x + { + typedef Arg result_type; + typedef Arg argument_type; + + explicit multiply_by_x(Arg x) : m_x(x) {} + Arg operator()(Arg x) const { return x * m_x; } + private: + Arg m_x; + }; + } +} + +#endif // include guard diff --git a/src/boost/libs/range/test/test_function/true_predicate.hpp b/src/boost/libs/range/test/test_function/true_predicate.hpp new file mode 100644 index 00000000..87a0dcaf --- /dev/null +++ b/src/boost/libs/range/test/test_function/true_predicate.hpp @@ -0,0 +1,29 @@ +// Boost.Range library +// +// Copyright Neil Groves 2010. Use, modification and +// distribution is subject to 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) +// +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_TRUE_PREDICATE_HPP_INCLUDED +#define BOOST_RANGE_TEST_TEST_FUNCTION_TRUE_PREDICATE_HPP_INCLUDED + +namespace boost +{ + namespace range_test_function + { + struct true_predicate + { + typedef bool result_type; + + bool operator()() const { return true; } + template<class Arg> bool operator()(Arg) const { return true; } + template<class Arg1, class Arg2> bool operator()(Arg1,Arg2) const { return true; } + }; + } +} + +#endif // include guard |