then.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*!
  2. @file
  3. Forward declares `boost::hana::then`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_FWD_THEN_HPP
  9. #define BOOST_HANA_FWD_THEN_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Sequentially compose two monadic actions, discarding any value
  14. //! produced by the first but not its effects.
  15. //! @ingroup group-Monad
  16. //!
  17. //!
  18. //! @param before
  19. //! The first `Monad` in the monadic composition chain. The result of
  20. //! this monad is ignored, but its effects are combined with that of the
  21. //! second monad.
  22. //!
  23. //! @param xs
  24. //! The second `Monad` in the monadic composition chain.
  25. //!
  26. //!
  27. //! Example
  28. //! -------
  29. //! @include example/then.cpp
  30. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  31. constexpr auto then = [](auto&& before, auto&& xs) -> decltype(auto) {
  32. return tag-dispatched;
  33. };
  34. #else
  35. template <typename M, typename = void>
  36. struct then_impl : then_impl<M, when<true>> { };
  37. struct then_t {
  38. template <typename Before, typename Xs>
  39. constexpr decltype(auto) operator()(Before&& before, Xs&& xs) const;
  40. };
  41. constexpr then_t then{};
  42. #endif
  43. BOOST_HANA_NAMESPACE_END
  44. #endif // !BOOST_HANA_FWD_THEN_HPP