basic_tuple.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*!
  2. @file
  3. Forward declares `boost::hana::basic_tuple`.
  4. Copyright Louis Dionne 2013-2022
  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_BASIC_TUPLE_HPP
  9. #define BOOST_HANA_FWD_BASIC_TUPLE_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/fwd/core/make.hpp>
  12. namespace boost { namespace hana {
  13. //! @ingroup group-datatypes
  14. //! Stripped down version of `hana::tuple`.
  15. //!
  16. //! Whereas `hana::tuple` aims to provide an interface somewhat close to a
  17. //! `std::tuple`, `basic_tuple` provides the strict minimum required to
  18. //! implement a closure with maximum compile-time efficiency.
  19. //!
  20. //! @note
  21. //! When you use a container, remember not to make assumptions about its
  22. //! representation, unless the documentation gives you those guarantees.
  23. //! More details [in the tutorial](@ref tutorial-containers-types).
  24. //!
  25. //!
  26. //! Modeled concepts
  27. //! ----------------
  28. //! `Sequence`, and all the concepts it refines
  29. template <typename ...Xs>
  30. struct basic_tuple;
  31. //! Tag representing `hana::basic_tuple`.
  32. //! @relates hana::basic_tuple
  33. struct basic_tuple_tag { };
  34. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  35. //! Function object for creating a `basic_tuple`.
  36. //! @relates hana::basic_tuple
  37. //!
  38. //! Given zero or more objects `xs...`, `make<basic_tuple_tag>` returns a
  39. //! new `basic_tuple` containing those objects. The elements are held by
  40. //! value inside the resulting tuple, and they are hence copied or moved
  41. //! in. This is analogous to `std::make_tuple` for creating `basic_tuple`s.
  42. //!
  43. //!
  44. //! Example
  45. //! -------
  46. //! @include example/basic_tuple/make.cpp
  47. template <>
  48. constexpr auto make<basic_tuple_tag> = [](auto&& ...xs) {
  49. return basic_tuple<std::decay_t<decltype(xs)>...>{forwarded(xs)...};
  50. };
  51. #endif
  52. //! Alias to `make<basic_tuple_tag>`; provided for convenience.
  53. //! @relates hana::basic_tuple
  54. //!
  55. //!
  56. //! Example
  57. //! -------
  58. //! @include example/basic_tuple/make.cpp
  59. BOOST_HANA_INLINE_VARIABLE constexpr auto make_basic_tuple = make<basic_tuple_tag>;
  60. }} // end namespace boost::hana
  61. #endif // !BOOST_HANA_FWD_BASIC_TUPLE_HPP