| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::accessors`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 6 | Distributed under the Boost Software License, Version 1.0. |
| 7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) |
| 8 | */ |
| 9 | |
| 10 | #ifndef BOOST_HANA_FWD_ACCESSORS_HPP |
| 11 | #define BOOST_HANA_FWD_ACCESSORS_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 18 | //! Returns a `Sequence` of pairs representing the accessors of the |
| 19 | //! data structure. |
| 20 | //! @ingroup group-Struct |
| 21 | //! |
| 22 | //! Given a `Struct` `S`, `accessors<S>()` is a `Sequence` of `Product`s |
| 23 | //! where the first element of each pair is the "name" of a member of |
| 24 | //! the `Struct`, and the second element of each pair is a function that |
| 25 | //! can be used to access that member when given an object of the proper |
| 26 | //! data type. As described in the global documentation for `Struct`, the |
| 27 | //! accessor functions in this sequence must be move-independent. |
| 28 | //! |
| 29 | //! |
| 30 | //! Example |
| 31 | //! ------- |
| 32 | //! @include example/accessors.cpp |
| 33 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 34 | template <typename S> |
| 35 | constexpr auto accessors = []() { |
| 36 | return tag-dispatched; |
| 37 | }; |
| 38 | #else |
| 39 | template <typename S, typename = void> |
| 40 | struct accessors_impl : accessors_impl<S, when<true>> { }; |
| 41 | |
| 42 | template <typename S> |
| 43 | struct accessors_t; |
| 44 | |
| 45 | template <typename S> |
| 46 | BOOST_HANA_INLINE_VARIABLE constexpr accessors_t<S> accessors{}; |
| 47 | #endif |
| 48 | }} // end namespace boost::hana |
| 49 | |
| 50 | #endif // !BOOST_HANA_FWD_ACCESSORS_HPP |
| 51 | |