cartesian_product.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*!
  2. @file
  3. Forward declares `boost::hana::cartesian_product`.
  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_CARTESIAN_PRODUCT_HPP
  9. #define BOOST_HANA_FWD_CARTESIAN_PRODUCT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Computes the cartesian product of a sequence of sequences.
  14. //! @ingroup group-Sequence
  15. //!
  16. //! Given a sequence of sequences, `cartesian_product` returns a new
  17. //! sequence of sequences containing the cartesian product of the
  18. //! original sequences. For this method to finish, a finite number
  19. //! of finite sequences must be provided.
  20. //!
  21. //! @note
  22. //! All the sequences must have the same tag, and that tag must also match
  23. //! that of the top-level sequence.
  24. //!
  25. //!
  26. //! Signature
  27. //! ---------
  28. //! Given a `Sequence` `S(T)`, the signature is
  29. //! \f[
  30. //! \mathtt{cartesian\_product} : S(S(T)) \to S(S(T))
  31. //! \f]
  32. //!
  33. //! @param xs
  34. //! A sequence of sequences of which the cartesian product is computed.
  35. //!
  36. //!
  37. //! Example
  38. //! -------
  39. //! @include example/cartesian_product.cpp
  40. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  41. constexpr auto cartesian_product = [](auto&& xs) {
  42. return tag-dispatched;
  43. };
  44. #else
  45. template <typename S, typename = void>
  46. struct cartesian_product_impl : cartesian_product_impl<S, when<true>> { };
  47. struct cartesian_product_t {
  48. template <typename Xs>
  49. constexpr auto operator()(Xs&& xs) const;
  50. };
  51. constexpr cartesian_product_t cartesian_product{};
  52. #endif
  53. BOOST_HANA_NAMESPACE_END
  54. #endif // !BOOST_HANA_FWD_CARTESIAN_PRODUCT_HPP