summaryrefslogtreecommitdiff
path: root/boost/metaparse/v1/foldl.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:38:45 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:39:52 +0900
commit5cde13f21d36c7224b0e13d11c4b49379ae5210d (patch)
treee8269ac85a4b0f7d416e2565fa4f451b5cb41351 /boost/metaparse/v1/foldl.hpp
parentd9ec475d945d3035377a0d89ed42e382d8988891 (diff)
downloadboost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.gz
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.bz2
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.zip
Imported Upstream version 1.61.0
Change-Id: I96a1f878d1e6164f01e9aadd5147f38fca448d90 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/metaparse/v1/foldl.hpp')
-rw-r--r--boost/metaparse/v1/foldl.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/boost/metaparse/v1/foldl.hpp b/boost/metaparse/v1/foldl.hpp
new file mode 100644
index 0000000000..b3938ee6ff
--- /dev/null
+++ b/boost/metaparse/v1/foldl.hpp
@@ -0,0 +1,65 @@
+#ifndef BOOST_METAPARSE_V1_FOLDL_HPP
+#define BOOST_METAPARSE_V1_FOLDL_HPP
+
+// Copyright Abel Sinkovics (abel@sinkovics.hu) 2011.
+// 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/metaparse/v1/accept.hpp>
+#include <boost/metaparse/v1/is_error.hpp>
+#include <boost/metaparse/v1/get_position.hpp>
+#include <boost/metaparse/v1/get_result.hpp>
+#include <boost/metaparse/v1/get_remaining.hpp>
+
+#include <boost/mpl/eval_if.hpp>
+
+namespace boost
+{
+ namespace metaparse
+ {
+ namespace v1
+ {
+ template <class P, class State, class ForwardOp>
+ struct foldl
+ {
+ private:
+ template <class Res>
+ struct apply_unchecked :
+ // foldl never returns error
+ // I need to use apply_wrap, and not apply, because apply would
+ // build a metafunction class from foldl<P, State, ForwardOp>
+ // when ForwardOp is a lambda expression.
+ foldl<
+ P,
+ typename ForwardOp::template apply<
+ typename State::type,
+ typename get_result<Res>::type
+ >,
+ ForwardOp
+ >::template apply<
+ typename get_remaining<Res>::type,
+ typename get_position<Res>::type
+ >
+ {};
+
+ template <class S, class Pos>
+ struct next_iteration : accept<typename State::type, S, Pos> {};
+ public:
+ typedef foldl type;
+
+ template <class S, class Pos>
+ struct apply :
+ boost::mpl::eval_if<
+ typename is_error<typename P::template apply<S, Pos> >::type,
+ next_iteration<S, Pos>,
+ apply_unchecked<typename P::template apply<S, Pos> >
+ >
+ {};
+ };
+ }
+ }
+}
+
+#endif
+