concat.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*!
  2. @file
  3. Forward declares `boost::hana::concat`.
  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_CONCAT_HPP
  9. #define BOOST_HANA_FWD_CONCAT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Combine two monadic structures together.
  14. //! @ingroup group-MonadPlus
  15. //!
  16. //! Given two monadic structures, `concat` combines them together and
  17. //! returns a new monadic structure. The exact definition of `concat`
  18. //! will depend on the exact model of MonadPlus at hand, but for
  19. //! sequences it corresponds intuitively to simple concatenation.
  20. //!
  21. //! Also note that combination is not required to be commutative.
  22. //! In other words, there is no requirement that
  23. //! @code
  24. //! concat(xs, ys) == concat(ys, xs)
  25. //! @endcode
  26. //! and indeed it does not hold in general.
  27. //!
  28. //!
  29. //! Signature
  30. //! ---------
  31. //! Given a `MonadPlus` `M`, the signature of `concat` is
  32. //! @f$ \mathtt{concat} : M(T) \times M(T) \to M(T) @f$.
  33. //!
  34. //! @param xs, ys
  35. //! Two monadic structures to combine together.
  36. //!
  37. //!
  38. //! Example
  39. //! -------
  40. //! @include example/concat.cpp
  41. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  42. constexpr auto concat = [](auto&& xs, auto&& ys) {
  43. return tag-dispatched;
  44. };
  45. #else
  46. template <typename M, typename = void>
  47. struct concat_impl : concat_impl<M, when<true>> { };
  48. struct concat_t {
  49. template <typename Xs, typename Ys>
  50. constexpr auto operator()(Xs&& xs, Ys&& ys) const;
  51. };
  52. constexpr concat_t concat{};
  53. #endif
  54. BOOST_HANA_NAMESPACE_END
  55. #endif // !BOOST_HANA_FWD_CONCAT_HPP