]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
9 | #ifndef BOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED | |
10 | #define BOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED | |
11 | ||
12 | #include <boost/mpl/apply.hpp> | |
13 | #include <boost/mpl/always.hpp> | |
14 | #include <boost/mpl/identity.hpp> | |
15 | #include <boost/mpl/placeholders.hpp> | |
16 | ||
17 | #include <boost/type_traits/remove_cv.hpp> | |
18 | #include <boost/type_traits/add_pointer.hpp> | |
19 | #include <boost/type_traits/add_reference.hpp> | |
20 | ||
21 | namespace boost { 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 | ||
31 | // We can short-circuit the mechanism implemented in the primary template for | |
32 | // the most common lambda expression and save both the "un-lambdaing" and the | |
33 | // type traits invocation (we know that T can only be a class type). | |
34 | ||
35 | template<typename T> struct class_transform< T, mpl::identity<_> > | |
36 | { typedef T type; }; | |
37 | ||
38 | template<typename T> struct class_transform< T, add_reference<_> > | |
39 | { typedef T & type; }; | |
40 | ||
41 | template<typename T> struct class_transform< T, add_pointer<_> > | |
42 | { typedef T * type; }; | |
43 | ||
44 | template<typename T> struct class_transform< T, remove_cv<_> > | |
45 | { typedef typename boost::remove_cv<T>::type type; }; | |
46 | ||
47 | template<typename T> struct class_transform< T, add_reference< remove_cv<_> > > | |
48 | { typedef typename boost::remove_cv<T>::type & type; }; | |
49 | ||
50 | template<typename T> struct class_transform< T, add_pointer< remove_cv<_> > > | |
51 | { typedef typename boost::remove_cv<T>::type * type; }; | |
52 | ||
53 | template<typename T, typename U> struct class_transform< T, mpl::always<U> > | |
54 | { typedef U type; }; | |
55 | ||
56 | ||
57 | } } } // namespace ::boost::function_types::detail | |
58 | ||
59 | #endif | |
60 |