Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // (C) Copyright Tobias Schwinger |
| 3 | // |
| 4 | // Use modification and distribution are subject to the boost Software License, |
| 5 | // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). |
| 6 | |
| 7 | //------------------------------------------------------------------------------ |
| 8 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 9 | #ifndef NDNBOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED |
| 10 | #define NDNBOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 11 | |
| 12 | #include <ndnboost/mpl/apply.hpp> |
| 13 | #include <ndnboost/mpl/always.hpp> |
| 14 | #include <ndnboost/mpl/identity.hpp> |
| 15 | #include <ndnboost/mpl/placeholders.hpp> |
| 16 | |
| 17 | #include <ndnboost/type_traits/remove_cv.hpp> |
| 18 | #include <ndnboost/type_traits/add_pointer.hpp> |
| 19 | #include <ndnboost/type_traits/add_reference.hpp> |
| 20 | |
| 21 | namespace ndnboost { namespace function_types { namespace detail { |
| 22 | |
| 23 | using mpl::placeholders::_; |
| 24 | |
| 25 | // Transformation metafunction for the class type of member function pointers. |
| 26 | template<typename T, typename L> |
| 27 | struct class_transform |
| 28 | { typedef typename mpl::apply1<L,T>::type type; }; |
| 29 | |
| 30 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 31 | #ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 32 | // We can short-circuit the mechanism implemented in the primary template for |
| 33 | // the most common lambda expression and save both the "un-lambdaing" and the |
| 34 | // type traits invocation (we know that T can only be a class type). |
| 35 | |
| 36 | template<typename T> struct class_transform< T, mpl::identity<_> > |
| 37 | { typedef T type; }; |
| 38 | |
| 39 | template<typename T> struct class_transform< T, add_reference<_> > |
| 40 | { typedef T & type; }; |
| 41 | |
| 42 | template<typename T> struct class_transform< T, add_pointer<_> > |
| 43 | { typedef T * type; }; |
| 44 | |
| 45 | template<typename T> struct class_transform< T, remove_cv<_> > |
| 46 | { typedef typename ndnboost::remove_cv<T>::type type; }; |
| 47 | |
| 48 | template<typename T> struct class_transform< T, add_reference< remove_cv<_> > > |
| 49 | { typedef typename ndnboost::remove_cv<T>::type & type; }; |
| 50 | |
| 51 | template<typename T> struct class_transform< T, add_pointer< remove_cv<_> > > |
| 52 | { typedef typename ndnboost::remove_cv<T>::type * type; }; |
| 53 | |
| 54 | template<typename T, typename U> struct class_transform< T, mpl::always<U> > |
| 55 | { typedef U type; }; |
| 56 | #endif |
| 57 | |
| 58 | |
| 59 | } } } // namespace ::ndnboost::function_types::detail |
| 60 | |
| 61 | #endif |
| 62 | |