unpack_sequence.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*=============================================================================
  2. Copyright (c) 2016 Paul Fultz II
  3. unpack_sequence.hpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_HOF_GUARD_UNPACK_SEQUENCE_HPP
  8. #define BOOST_HOF_GUARD_UNPACK_SEQUENCE_HPP
  9. /// unpack_sequence
  10. /// ===============
  11. ///
  12. /// How to unpack a sequence can be defined by specializing `unpack_sequence`.
  13. /// By default, `std::tuple` is already specialized. To implement this, one
  14. /// needs to provide a static `apply` function which will unpack the sequence
  15. /// to the parameters of the function.
  16. ///
  17. /// Synopsis
  18. /// --------
  19. ///
  20. /// template<class Sequence, class=void>
  21. /// struct unpack_sequence;
  22. ///
  23. /// Example
  24. /// -------
  25. ///
  26. /// #include <boost/hof.hpp>
  27. /// #include <cassert>
  28. ///
  29. /// struct my_sequence
  30. /// {
  31. /// int x;
  32. /// int y;
  33. /// };
  34. ///
  35. /// namespace boost { namespace hof {
  36. /// template<>
  37. /// struct unpack_sequence<my_sequence>
  38. /// {
  39. /// template<class F, class Sequence>
  40. /// constexpr static auto apply(F&& f, Sequence&& s) BOOST_HOF_RETURNS
  41. /// (
  42. /// f(s.x, s.y)
  43. /// );
  44. /// };
  45. /// }} // namespace boost::hof
  46. ///
  47. /// int main() {
  48. /// }
  49. ///
  50. /// See Also
  51. /// --------
  52. ///
  53. /// * [unpack](unpack)
  54. /// * [is_unpackable](is_unpackable)
  55. ///
  56. #include <boost/hof/config.hpp>
  57. namespace boost { namespace hof {
  58. template<class Sequence, class=void>
  59. struct unpack_sequence
  60. {
  61. typedef void not_unpackable;
  62. };
  63. }} // namespace boost::hof
  64. #endif