| 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 | |
| 8 | #ifndef BOOST_HOF_GUARD_UNPACK_SEQUENCE_HPP |
| 9 | #define BOOST_HOF_GUARD_UNPACK_SEQUENCE_HPP |
| 10 | |
| 11 | /// unpack_sequence |
| 12 | /// =============== |
| 13 | /// |
| 14 | /// How to unpack a sequence can be defined by specializing `unpack_sequence`. |
| 15 | /// By default, `std::tuple` is already specialized. To implement this, one |
| 16 | /// needs to provide a static `apply` function which will unpack the sequence |
| 17 | /// to the parameters of the function. |
| 18 | /// |
| 19 | /// Synopsis |
| 20 | /// -------- |
| 21 | /// |
| 22 | /// template<class Sequence, class=void> |
| 23 | /// struct unpack_sequence; |
| 24 | /// |
| 25 | /// Example |
| 26 | /// ------- |
| 27 | /// |
| 28 | /// #include <boost/hof.hpp> |
| 29 | /// #include <cassert> |
| 30 | /// |
| 31 | /// struct my_sequence |
| 32 | /// { |
| 33 | /// int x; |
| 34 | /// int y; |
| 35 | /// }; |
| 36 | /// |
| 37 | /// namespace boost { namespace hof { |
| 38 | /// template<> |
| 39 | /// struct unpack_sequence<my_sequence> |
| 40 | /// { |
| 41 | /// template<class F, class Sequence> |
| 42 | /// constexpr static auto apply(F&& f, Sequence&& s) BOOST_HOF_RETURNS |
| 43 | /// ( |
| 44 | /// f(s.x, s.y) |
| 45 | /// ); |
| 46 | /// }; |
| 47 | /// }} // namespace boost::hof |
| 48 | /// |
| 49 | /// int main() { |
| 50 | /// } |
| 51 | /// |
| 52 | /// See Also |
| 53 | /// -------- |
| 54 | /// |
| 55 | /// * [unpack](unpack) |
| 56 | /// * [is_unpackable](is_unpackable) |
| 57 | /// |
| 58 | |
| 59 | #include <boost/hof/config.hpp> |
| 60 | |
| 61 | namespace boost { namespace hof { |
| 62 | |
| 63 | template<class Sequence, class=void> |
| 64 | struct unpack_sequence |
| 65 | { |
| 66 | typedef void not_unpackable; |
| 67 | }; |
| 68 | |
| 69 | }} // namespace boost::hof |
| 70 | |
| 71 | #endif |
| 72 | |