Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:04

0001 /*!
0002 @file
0003 Defines `boost::hana::members`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_MEMBERS_HPP
0011 #define BOOST_HANA_MEMBERS_HPP
0012 
0013 #include <boost/hana/fwd/members.hpp>
0014 
0015 #include <boost/hana/accessors.hpp>
0016 #include <boost/hana/concept/struct.hpp>
0017 #include <boost/hana/config.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019 #include <boost/hana/second.hpp>
0020 #include <boost/hana/transform.hpp>
0021 
0022 
0023 namespace boost { namespace hana {
0024     //! @cond
0025     template <typename Object>
0026     constexpr auto members_t::operator()(Object&& object) const {
0027         using S = typename hana::tag_of<Object>::type;
0028         using Members = BOOST_HANA_DISPATCH_IF(members_impl<S>,
0029             hana::Struct<S>::value
0030         );
0031 
0032         #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0033             static_assert(hana::Struct<S>::value,
0034             "hana::members(object) requires 'object' to be a Struct");
0035         #endif
0036 
0037         return Members::apply(static_cast<Object&&>(object));
0038     }
0039     //! @endcond
0040 
0041     namespace struct_detail {
0042         template <typename Holder, typename Forward>
0043         struct members_helper {
0044             Holder object;
0045             template <typename Accessor>
0046             constexpr decltype(auto) operator()(Accessor&& accessor) const {
0047                 return hana::second(static_cast<Accessor&&>(accessor))(
0048                     static_cast<Forward>(object)
0049                 );
0050             }
0051         };
0052     }
0053 
0054     template <typename S, bool condition>
0055     struct members_impl<S, when<condition>> : default_ {
0056         template <typename Object>
0057         static constexpr auto apply(Object&& object) {
0058             return hana::transform(hana::accessors<S>(),
0059                 struct_detail::members_helper<Object&, Object&&>{object}
0060             );
0061         }
0062     };
0063 }} // end namespace boost::hana
0064 
0065 #endif // !BOOST_HANA_MEMBERS_HPP