blob: 56ace172a41efb4824ac99309934656593d89c6d [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
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
9#ifndef BOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED
10#define BOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED
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
21namespace ndnboost { namespace function_types { namespace detail {
22
23using mpl::placeholders::_;
24
25// Transformation metafunction for the class type of member function pointers.
26template<typename T, typename L>
27struct class_transform
28{ typedef typename mpl::apply1<L,T>::type type; };
29
30
31#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
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
36template<typename T> struct class_transform< T, mpl::identity<_> >
37{ typedef T type; };
38
39template<typename T> struct class_transform< T, add_reference<_> >
40{ typedef T & type; };
41
42template<typename T> struct class_transform< T, add_pointer<_> >
43{ typedef T * type; };
44
45template<typename T> struct class_transform< T, remove_cv<_> >
46{ typedef typename ndnboost::remove_cv<T>::type type; };
47
48template<typename T> struct class_transform< T, add_reference< remove_cv<_> > >
49{ typedef typename ndnboost::remove_cv<T>::type & type; };
50
51template<typename T> struct class_transform< T, add_pointer< remove_cv<_> > >
52{ typedef typename ndnboost::remove_cv<T>::type * type; };
53
54template<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