Edit: /usr/include/boost/hana/unfold_left.hpp (2204B)
/*!
@file
Defines `boost::hana::unfold_left`.
@copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_HANA_UNFOLD_LEFT_HPP
#define BOOST_HANA_UNFOLD_LEFT_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
BOOST_HANA_NAMESPACE_BEGIN
//! @cond
template
struct unfold_left_t {
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Sequence::value,
"hana::unfold_left requires 'S' to be a Sequence");
#endif
template
constexpr auto operator()(State&& state, F&& f) const {
return unfold_left_impl::apply(
static_cast(state),
static_cast(f)
);
}
};
//! @endcond
template
struct unfold_left_impl> : default_ {
struct unfold_left_helper {
template
constexpr auto operator()(F&& f, P&& p) const {
return hana::append(
unfold_left_impl::apply(
hana::first(static_cast(p)),
static_cast(f)
),
hana::second(static_cast(p))
);
}
};
template
static constexpr auto apply(Init&& init, F&& f) {
decltype(auto) elt = f(static_cast(init));
return hana::maybe(empty(),
hana::partial(unfold_left_helper{}, static_cast(f)),
static_cast(elt)
);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_UNFOLD_LEFT_HPP