summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/proto/test/mpl.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/proto/test/mpl.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/proto/test/mpl.cpp')
-rw-r--r--src/boost/libs/proto/test/mpl.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/boost/libs/proto/test/mpl.cpp b/src/boost/libs/proto/test/mpl.cpp
new file mode 100644
index 00000000..292e582b
--- /dev/null
+++ b/src/boost/libs/proto/test/mpl.cpp
@@ -0,0 +1,67 @@
+///////////////////////////////////////////////////////////////////////////////
+// mpl.hpp
+//
+// Copyright 2012 Eric Niebler. 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/proto/proto.hpp>
+#include <boost/fusion/mpl.hpp>
+#include <boost/mpl/pop_back.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/test/unit_test.hpp>
+namespace mpl = boost::mpl;
+namespace proto = boost::proto;
+namespace fusion = boost::fusion;
+using proto::_;
+
+template<class E>
+struct my_expr;
+
+struct my_domain
+ : proto::domain<proto::generator<my_expr> >
+{};
+
+template<class E>
+struct my_expr
+ : proto::extends<E, my_expr<E>, my_domain>
+{
+ my_expr(E const &e = E())
+ : proto::extends<E, my_expr<E>, my_domain>(e)
+ {}
+
+ typedef fusion::fusion_sequence_tag tag;
+};
+
+template<typename T>
+void test_impl(T const &)
+{
+ typedef typename mpl::pop_back<T>::type result_type;
+ BOOST_STATIC_ASSERT(
+ (boost::is_same<
+ result_type
+ , my_expr<proto::basic_expr<proto::tag::plus, proto::list1<my_expr<proto::terminal<int>::type>&> > >
+ >::value)
+ );
+}
+
+// Test that we can call mpl algorithms on proto expression types, and get proto expression types back
+void test_mpl()
+{
+ my_expr<proto::terminal<int>::type> i;
+ test_impl(i + i);
+}
+
+using namespace boost::unit_test;
+///////////////////////////////////////////////////////////////////////////////
+// init_unit_test_suite
+//
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("test proto mpl integration via fusion");
+
+ test->add(BOOST_TEST_CASE(&test_mpl));
+
+ return test;
+}