summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/parameter/test/earwicker.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/parameter/test/earwicker.cpp
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.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/parameter/test/earwicker.cpp')
-rw-r--r--src/boost/libs/parameter/test/earwicker.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/boost/libs/parameter/test/earwicker.cpp b/src/boost/libs/parameter/test/earwicker.cpp
new file mode 100644
index 00000000..16c87123
--- /dev/null
+++ b/src/boost/libs/parameter/test/earwicker.cpp
@@ -0,0 +1,125 @@
+// Copyright David Abrahams, Daniel Wallin 2005.
+// 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/parameter/config.hpp>
+
+#if (BOOST_PARAMETER_MAX_ARITY < 4)
+#error Define BOOST_PARAMETER_MAX_ARITY as 4 or greater.
+#endif
+#if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \
+ (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 5)
+#error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
+as 5 or greater.
+#endif
+
+#include <boost/parameter/name.hpp>
+
+namespace test {
+
+ BOOST_PARAMETER_NAME(w)
+ BOOST_PARAMETER_NAME(x)
+ BOOST_PARAMETER_NAME(y)
+ BOOST_PARAMETER_NAME(z)
+} // namespace test
+
+#if !defined(BOOST_PARAMETER_CAN_USE_MP11)
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+
+namespace test {
+
+ struct f_predicate
+ {
+ template <typename T, typename Args>
+ struct apply
+ : boost::mpl::if_<
+ boost::is_convertible<T,int>
+ , boost::mpl::true_
+ , boost::mpl::false_
+ >
+ {
+ };
+ };
+} // namespace test
+
+#endif // BOOST_PARAMETER_CAN_USE_MP11
+
+#include <boost/parameter/parameters.hpp>
+
+#if defined(BOOST_PARAMETER_CAN_USE_MP11)
+#include <boost/mp11/bind.hpp>
+#include <type_traits>
+#endif
+
+namespace test {
+
+ struct f_parameters // vc6 is happier with inheritance than with a typedef
+ : boost::parameter::parameters<
+ boost::parameter::required<test::tag::w>
+#if defined(BOOST_PARAMETER_CAN_USE_MP11)
+ , boost::parameter::optional<
+ test::tag::x
+ , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int>
+ >
+ , boost::parameter::optional<
+ test::tag::y
+ , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int>
+ >
+ , boost::parameter::optional<
+ test::tag::z
+ , boost::mp11::mp_bind<std::is_convertible,boost::mp11::_1,int>
+ >
+#else
+ , boost::parameter::optional<test::tag::x,test::f_predicate>
+ , boost::parameter::optional<test::tag::y,test::f_predicate>
+ , boost::parameter::optional<test::tag::z,test::f_predicate>
+#endif // BOOST_PARAMETER_CAN_USE_MP11
+ >
+ {
+ };
+} // namespace test
+
+#include <boost/parameter/macros.hpp>
+#include <boost/core/lightweight_test.hpp>
+
+namespace test {
+
+#if defined(BOOST_NO_VOID_RETURNS)
+ BOOST_PARAMETER_FUN(int, f, 1, 4, f_parameters)
+#else
+ BOOST_PARAMETER_FUN(void, f, 1, 4, f_parameters)
+#endif
+ {
+ BOOST_TEST_EQ(p[test::_w][0], p[test::_x | -1]);
+ BOOST_TEST_EQ(p[test::_w][1], p[test::_y | -2]);
+ BOOST_TEST_EQ(p[test::_w][2], p[test::_z | -3]);
+#if defined(BOOST_NO_VOID_RETURNS)
+ return 0;
+#endif
+ }
+} // namespace test
+
+int main()
+{
+ int a[3];
+ a[0] = 1;
+ a[1] = 2;
+ a[2] = 3;
+ test::f(test::_x = 1, test::_y = 2, test::_z = 3, test::_w = a);
+ a[1] = -2;
+ a[2] = -3;
+ test::f(test::_x = 1, test::_w = a);
+ a[0] = -1;
+ a[1] = 2;
+ test::f(test::_y = 2, test::_w = a);
+ a[1] = -2;
+ a[2] = 3;
+ test::f(test::_z = 3, test::_w = a);
+ a[0] = 1;
+ test::f(test::_z = 3, test::_x = 1, test::_w = a);
+ return boost::report_errors();
+}
+