class_transform.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. #ifndef BOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED
  7. #define BOOST_FT_DETAIL_CLASS_TRANSFORM_HPP_INCLUDED
  8. #include <boost/mpl/apply.hpp>
  9. #include <boost/mpl/always.hpp>
  10. #include <boost/mpl/identity.hpp>
  11. #include <boost/mpl/placeholders.hpp>
  12. #include <boost/type_traits/remove_cv.hpp>
  13. #include <boost/type_traits/add_pointer.hpp>
  14. #include <boost/type_traits/add_reference.hpp>
  15. namespace boost { namespace function_types { namespace detail {
  16. using mpl::placeholders::_;
  17. // Transformation metafunction for the class type of member function pointers.
  18. template<typename T, typename L>
  19. struct class_transform
  20. { typedef typename mpl::apply1<L,T>::type type; };
  21. // We can short-circuit the mechanism implemented in the primary template for
  22. // the most common lambda expression and save both the "un-lambdaing" and the
  23. // type traits invocation (we know that T can only be a class type).
  24. template<typename T> struct class_transform< T, mpl::identity<_> >
  25. { typedef T type; };
  26. template<typename T> struct class_transform< T, add_reference<_> >
  27. { typedef T & type; };
  28. template<typename T> struct class_transform< T, add_pointer<_> >
  29. { typedef T * type; };
  30. template<typename T> struct class_transform< T, remove_cv<_> >
  31. { typedef typename boost::remove_cv<T>::type type; };
  32. template<typename T> struct class_transform< T, add_reference< remove_cv<_> > >
  33. { typedef typename boost::remove_cv<T>::type & type; };
  34. template<typename T> struct class_transform< T, add_pointer< remove_cv<_> > >
  35. { typedef typename boost::remove_cv<T>::type * type; };
  36. template<typename T, typename U> struct class_transform< T, mpl::always<U> >
  37. { typedef U type; };
  38. } } } // namespace ::boost::function_types::detail
  39. #endif