]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines operators for Monads. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
6 | Distributed under the Boost Software License, Version 1.0. | |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_DETAIL_OPERATORS_MONAD_HPP | |
11 | #define BOOST_HANA_DETAIL_OPERATORS_MONAD_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/tag_of.hpp> | |
15 | #include <boost/hana/fwd/chain.hpp> | |
16 | ||
17 | #include <type_traits> | |
18 | ||
19 | ||
20 | BOOST_HANA_NAMESPACE_BEGIN namespace detail { | |
21 | template <typename Tag> | |
22 | struct monad_operators { | |
23 | static constexpr bool value = false; | |
24 | }; | |
25 | ||
26 | namespace operators { | |
27 | template <typename Xs, typename F, typename = typename std::enable_if< | |
28 | detail::monad_operators<typename hana::tag_of<Xs>::type>::value | |
29 | >::type> | |
30 | constexpr auto operator|(Xs&& xs, F&& f) | |
31 | { return hana::chain(static_cast<Xs&&>(xs), static_cast<F&&>(f)); } | |
32 | } // end namespace operators | |
33 | } BOOST_HANA_NAMESPACE_END | |
34 | ||
35 | #endif // !BOOST_HANA_DETAIL_OPERATORS_MONAD_HPP |