/Src/Dependencies/Boost/boost/function_types/detail/class_transform.hpp

http://hadesmem.googlecode.com/ · C++ Header · 62 lines · 32 code · 21 blank · 9 comment · 0 complexity · f1ae06b5a5fc6ba067d51c1e01761ab4 MD5 · raw file

  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. #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
  22. // We can short-circuit the mechanism implemented in the primary template for
  23. // the most common lambda expression and save both the "un-lambdaing" and the
  24. // type traits invocation (we know that T can only be a class type).
  25. template<typename T> struct class_transform< T, mpl::identity<_> >
  26. { typedef T type; };
  27. template<typename T> struct class_transform< T, add_reference<_> >
  28. { typedef T & type; };
  29. template<typename T> struct class_transform< T, add_pointer<_> >
  30. { typedef T * type; };
  31. template<typename T> struct class_transform< T, remove_cv<_> >
  32. { typedef typename boost::remove_cv<T>::type type; };
  33. template<typename T> struct class_transform< T, add_reference< remove_cv<_> > >
  34. { typedef typename boost::remove_cv<T>::type & type; };
  35. template<typename T> struct class_transform< T, add_pointer< remove_cv<_> > >
  36. { typedef typename boost::remove_cv<T>::type * type; };
  37. template<typename T, typename U> struct class_transform< T, mpl::always<U> >
  38. { typedef U type; };
  39. #endif
  40. } } } // namespace ::boost::function_types::detail
  41. #endif