Edit: /usr/include/boost/hana/unfold_right.hpp (2224B)
/*!
@file
Defines `boost::hana::unfold_right`.
@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_RIGHT_HPP
#define BOOST_HANA_UNFOLD_RIGHT_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
BOOST_HANA_NAMESPACE_BEGIN
//! @cond
template
struct unfold_right_t {
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Sequence::value,
"hana::unfold_right requires 'S' to be a Sequence");
#endif
template
constexpr auto operator()(State&& state, F&& f) const {
return unfold_right_impl::apply(
static_cast(state),
static_cast(f)
);
}
};
//! @endcond
template
struct unfold_right_impl> : default_ {
struct unfold_right_helper {
template
constexpr auto operator()(F&& f, P&& p) const {
return hana::prepend(
unfold_right_impl::apply(
hana::second(static_cast(p)),
static_cast(f)
),
hana::first(static_cast(p))
);
}
};
template
static constexpr auto apply(Init&& init, F&& f) {
decltype(auto) elt = f(static_cast(init));
return hana::maybe(hana::empty(),
hana::partial(unfold_right_helper{}, static_cast(f)),
static_cast(elt)
);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_UNFOLD_RIGHT_HPP