3 Defines `boost::hana::accessors`.
5 @copyright Louis Dionne 2013-2016
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)
10 #ifndef BOOST_HANA_ACCESSORS_HPP
11 #define BOOST_HANA_ACCESSORS_HPP
13 #include <boost/hana/fwd/accessors.hpp>
15 #include <boost/hana/concept/struct.hpp>
16 #include <boost/hana/config.hpp>
17 #include <boost/hana/core/dispatch.hpp>
20 BOOST_HANA_NAMESPACE_BEGIN
23 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
24 static_assert(hana::Struct<S>::value,
25 "hana::accessors<S> requires 'S' to be a Struct");
28 constexpr decltype(auto) operator()() const {
29 using Accessors = BOOST_HANA_DISPATCH_IF(accessors_impl<S>,
30 hana::Struct<S>::value
33 return Accessors::apply();
37 template <typename S, bool condition>
38 struct accessors_impl<S, when<condition>> : default_ {
39 template <typename ...Args>
40 static constexpr auto apply(Args&& ...) = delete;
43 namespace struct_detail {
44 template <typename ...>
45 struct is_valid { static constexpr bool value = true; };
49 struct accessors_impl<S, when<
50 struct_detail::is_valid<typename S::hana_accessors_impl>::value
52 : S::hana_accessors_impl
54 BOOST_HANA_NAMESPACE_END
56 #endif // !BOOST_HANA_ACCESSORS_HPP