/* Defines `qualifier_flags` @Copyright Barrett Adair 2015-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_CLBL_TRTS_QUALIFIER_FLAGS_HPP #define BOOST_CLBL_TRTS_QUALIFIER_FLAGS_HPP #include namespace boost { namespace callable_traits { namespace detail { //bit qualifier_flags used to signify cv/ref qualifiers using qualifier_flags = std::uint32_t; /* | && & V C | -------------------------------------------- 0 | 0 0 0 0 | default 1 | 0 0 0 1 | const 2 | 0 0 1 0 | volatile 3 | 0 0 1 1 | const volatile -------------------------------------------- 4 | 0 1 0 0 | & 5 | 0 1 0 1 | const & 6 | 0 1 1 0 | volatile & 7 | 0 1 1 1 | const volatile & -------------------------------------------- 8 | 1 0 0 0 | && 9 | 1 0 0 1 | const && 10 | 1 0 1 0 | volatile && 11 | 1 0 1 1 | const volatile && */ // Flag representing the default qualifiers on a type // or member function overload. constexpr qualifier_flags default_ = 0; // Flag representing a const qualifier on a type or // member function overload. constexpr qualifier_flags const_ = 1; // Flag representing a volatile qualifier on a type // or member function overload. constexpr qualifier_flags volatile_ = 2; #ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS constexpr qualifier_flags lref_ = default_; constexpr qualifier_flags rref_ = default_; #else // Flag representing an lvalue reference type, or // an lvalue-reference-qualified member function // overload. constexpr qualifier_flags lref_ = 4; // Flag representing an lvalue reference type, or // an rvalue-reference-qualified member function // overload. constexpr qualifier_flags rref_ = 8; #endif //#ifdef BOOST_CLBL_TRTS_DISABLE_REFERENCE_QUALIFIERS constexpr qualifier_flags cv_ = 3; template using remove_const_flag = std::integral_constant< qualifier_flags, Flags & ~const_>; template using is_const = std::integral_constant; template using remove_volatile_flag = std::integral_constant< qualifier_flags, Flags & ~volatile_>; template::type> using cv_of = std::integral_constant::value ? const_ : default_) | (std::is_volatile::value ? volatile_ : default_)>; template using ref_of = std::integral_constant::value ? rref_ : (std::is_lvalue_reference::value ? lref_ : default_)>; //bit-flag implementation of C++11 reference collapsing rules template using collapse_flags = std::integral_constant; template struct flag_map { static constexpr qualifier_flags value = default_; }; template struct flag_map { static constexpr qualifier_flags value = lref_; }; template struct flag_map { static constexpr qualifier_flags value = rref_; }; template struct flag_map { static constexpr qualifier_flags value = const_; }; template struct flag_map { static constexpr qualifier_flags value = const_ | lref_; }; template struct flag_map { static constexpr qualifier_flags value = const_ | rref_; }; template struct flag_map { static constexpr qualifier_flags value = volatile_; }; template struct flag_map { static constexpr qualifier_flags value = volatile_ | lref_; }; template struct flag_map { static constexpr qualifier_flags value = volatile_ | rref_; }; template struct flag_map { static constexpr qualifier_flags value = const_ | volatile_; }; template struct flag_map { static constexpr qualifier_flags value = const_ | volatile_ | lref_; }; template struct flag_map { static constexpr qualifier_flags value = const_ | volatile_ | rref_; }; }}} // namespace boost::callable_traits::detail #endif // #ifndef BOOST_CLBL_TRTS_QUALIFIER_FLAGS_HPP