summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/metaparse/example/meta_hs/curry.hpp
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/metaparse/example/meta_hs/curry.hpp
parentInitial commit. (diff)
downloadceph-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/metaparse/example/meta_hs/curry.hpp')
-rw-r--r--src/boost/libs/metaparse/example/meta_hs/curry.hpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/boost/libs/metaparse/example/meta_hs/curry.hpp b/src/boost/libs/metaparse/example/meta_hs/curry.hpp
new file mode 100644
index 00000000..5ca1711d
--- /dev/null
+++ b/src/boost/libs/metaparse/example/meta_hs/curry.hpp
@@ -0,0 +1,106 @@
+#ifndef BOOST_METAPARSE_META_HS_CURRY_HPP
+#define BOOST_METAPARSE_META_HS_CURRY_HPP
+
+// Copyright Abel Sinkovics (abel@sinkovics.hu) 2010.
+// 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/mpl/eval_if.hpp>
+#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/minus.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/unpack_args.hpp>
+#include <boost/mpl/deque.hpp>
+#include <boost/mpl/quote.hpp>
+
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+
+#ifndef CURRY_MAX_ARGUMENT
+# define CURRY_MAX_ARGUMENT 5
+#endif
+
+namespace impl
+{
+ template <
+ class UnpackedMetafunctionClass,
+ class ArgumentsLeft,
+ class ArgumentList
+ >
+ struct curry_impl;
+
+
+
+ template <
+ class UnpackedMetafunctionClass,
+ class ArgumentsLeft,
+ class ArgumentList
+ >
+ struct next_currying_step
+ {
+ typedef next_currying_step type;
+
+ template <class T>
+ struct apply :
+ curry_impl<
+ UnpackedMetafunctionClass,
+ typename boost::mpl::minus<
+ ArgumentsLeft,
+ boost::mpl::int_<1>
+ >::type,
+ typename boost::mpl::push_back<ArgumentList, T>::type
+ >
+ {};
+ };
+
+
+ template <
+ class UnpackedMetafunctionClass,
+ class ArgumentsLeft,
+ class ArgumentList
+ >
+ struct curry_impl :
+ boost::mpl::eval_if<
+ typename boost::mpl::equal_to<
+ ArgumentsLeft,
+ boost::mpl::int_<0>
+ >::type,
+ boost::mpl::apply<UnpackedMetafunctionClass, ArgumentList>,
+ next_currying_step<
+ UnpackedMetafunctionClass,
+ ArgumentsLeft,
+ ArgumentList
+ >
+ >
+ {};
+}
+
+
+template <class T>
+struct curry0 : T {};
+
+#ifdef CURRY
+# error CURRY already defined
+#endif
+#define CURRY(z, n, unused) \
+ template <template <BOOST_PP_ENUM(n,class BOOST_PP_TUPLE_EAT(3),~)> class T> \
+ struct BOOST_PP_CAT(curry, n) : \
+ impl::curry_impl< \
+ boost::mpl::unpack_args<boost::mpl::BOOST_PP_CAT(quote, n) <T> >, \
+ boost::mpl::int_<n>, \
+ boost::mpl::deque<> \
+ >::type \
+ {};
+
+BOOST_PP_REPEAT_FROM_TO(1, CURRY_MAX_ARGUMENT, CURRY, ~)
+
+#undef CURRY
+
+#endif
+