1 /* 2 3 @Copyright Barrett Adair 2015-2017 4 Distributed under the Boost Software License, Version 1.0. 5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 6 7 */ 8 9 #ifndef BOOST_CLBL_TRTS_class_of_HPP 10 #define BOOST_CLBL_TRTS_class_of_HPP 11 12 #include <boost/callable_traits/detail/core.hpp> 13 14 namespace boost { namespace callable_traits { 15 16 //[ class_of_hpp 17 /*` 18 [section:ref_class_of class_of] 19 [heading Header] 20 ``#include <boost/callable_traits/class_of.hpp>`` 21 [heading Definition] 22 */ 23 24 template<typename T> 25 using class_of_t = //see below 26 //<- 27 detail::try_but_fail_if_invalid< 28 typename detail::traits<detail::shallow_decay<T>>::class_type, 29 type_is_not_a_member_pointer>; 30 31 namespace detail { 32 33 template<typename T, typename = std::false_type> 34 struct class_of_impl {}; 35 36 template<typename T> 37 struct class_of_impl <T, typename std::is_same< 38 class_of_t<T>, detail::dummy>::type> 39 { 40 using type = class_of_t<T>; 41 }; 42 } 43 44 //-> 45 46 template<typename T> 47 struct class_of : detail::class_of_impl<T> {}; 48 49 //<- 50 }} // namespace boost::callable_traits 51 //-> 52 53 /*` 54 [heading Constraints] 55 * `T` must be a member pointer 56 57 [heading Behavior] 58 * A substitution failure occurs if the constraints are violated. 59 * The aliased type is the parent class of the member. In other words, if `T` is expanded to `U C::*`, the aliased type is `C`. 60 61 [heading Input/Output Examples] 62 [table 63 [[`T`] [`class_of_t<T>`]] 64 [[`int foo::*`] [`foo`]] 65 [[`void(foo::* const &)() const`] [`foo`]] 66 ] 67 68 [heading Example Program] 69 [import ../example/class_of.cpp] 70 [class_of] 71 [endsect] 72 */ 73 //] 74 75 #endif // #ifndef BOOST_CLBL_TRTS_class_of_HPP 76