12 #ifndef BOOST_MPL11_FOLDABLE_HPP
13 #define BOOST_MPL11_FOLDABLE_HPP
26 namespace boost {
namespace mpl11 {
27 template <
typename Datatype,
typename>
28 struct Foldable : false_ { };
31 struct instantiate<Foldable> {
36 template <
typename x,
typename y>
37 using apply = just<maybe<x, partial<f, x>, y>>;
41 template <
typename Datatype>
43 template <
typename f,
typename structure>
44 using foldr1_impl = from_just<
45 foldr<maybe_f<f>, nothing, box<structure>>
48 template <
typename f,
typename structure>
49 using foldl1_impl = from_just<
50 foldl<flip<maybe_f<flip<f>>>, nothing, box<structure>>
55 template <
typename f,
typename state,
typename structure>
57 Foldable<typename datatype<typename structure::type>::type>::
58 template foldr_impl<f, state, typename structure::type>
61 template <
typename f,
typename state,
typename structure>
63 Foldable<typename datatype<typename structure::type>::type>::
64 template foldl_impl<f, state, typename structure::type>
67 namespace foldable_detail {
68 template <
typename xs>
71 template <
typename structure>
73 static_assert(!is_empty_structure<structure>::value,
74 "Invalid usage of foldr1 or foldl1 with an empty structure.");
78 template <
typename f,
typename structure>
81 Foldable<typename datatype<typename structure::type>::type>::
82 template foldr1_impl<f, typename structure::type>
85 template <
typename f,
typename structure>
88 Foldable<typename datatype<typename structure::type>::type>::
89 template foldl1_impl<f, typename structure::type>
93 #endif // !BOOST_MPL11_FOLDABLE_HPP
Manages configurable options of the library and defines utility macros.
Defines the Maybe datatype.
Defines the Logical module.
Variant of foldl that has no base case, and thus may only be applied to non-empty structures...
Definition: foldable.hpp:86
Right-associative fold of a structure using a binary operation.
Definition: foldable.hpp:56
#define BOOST_MPL11_IF_ASSERTIONS(...)
Macro expanding to its argument(s) if BOOST_MPL11_NO_ASSERTIONS is not defined, and to nothing otherw...
Definition: config.hpp:72
Invokes a metafunction class with the given arguments.
Definition: functional.hpp:39
Alias to bool_; provided for convenience.
Definition: integer.hpp:79
Left-associative fold of a structure using a binary operation.
Definition: foldable.hpp:62
Forwards to boost/mpl11/integer.hpp.
Variant of foldr that has no base case, and thus may only be applied to non-empty structures...
Definition: foldable.hpp:79
Defines the Functional module.
Forward declares the Foldable typeclass.