accessors.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*!
  2. @file
  3. Forward declares `boost::hana::accessors`.
  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_ACCESSORS_HPP
  9. #define BOOST_HANA_FWD_ACCESSORS_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Returns a `Sequence` of pairs representing the accessors of the
  14. //! data structure.
  15. //! @ingroup group-Struct
  16. //!
  17. //! Given a `Struct` `S`, `accessors<S>()` is a `Sequence` of `Product`s
  18. //! where the first element of each pair is the "name" of a member of
  19. //! the `Struct`, and the second element of each pair is a function that
  20. //! can be used to access that member when given an object of the proper
  21. //! data type. As described in the global documentation for `Struct`, the
  22. //! accessor functions in this sequence must be move-independent.
  23. //!
  24. //!
  25. //! Example
  26. //! -------
  27. //! @include example/accessors.cpp
  28. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  29. template <typename S>
  30. constexpr auto accessors = []() {
  31. return tag-dispatched;
  32. };
  33. #else
  34. template <typename S, typename = void>
  35. struct accessors_impl : accessors_impl<S, when<true>> { };
  36. template <typename S>
  37. struct accessors_t;
  38. template <typename S>
  39. constexpr accessors_t<S> accessors{};
  40. #endif
  41. BOOST_HANA_NAMESPACE_END
  42. #endif // !BOOST_HANA_FWD_ACCESSORS_HPP