add_pointed_const.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #ifndef BOOST_LOCAL_FUNCTION_AUX_ADD_POINTED_CONST_HPP_
  7. #define BOOST_LOCAL_FUNCTION_AUX_ADD_POINTED_CONST_HPP_
  8. namespace boost { namespace local_function { namespace aux {
  9. // Metafunction to add const to pointed type `T` (i.e. converts
  10. // `T* [const]` to `T const* [const]`). `boost::add_const<>` cannot be used
  11. // instead because only adds outer const.
  12. template<typename T> struct add_pointed_const { typedef T type; };
  13. template<typename T> struct add_pointed_const<T*> { typedef T const* type; };
  14. template<typename T> struct add_pointed_const<T const*>
  15. { typedef T const* type; };
  16. template<typename T> struct add_pointed_const<T* const>
  17. { typedef T const* const type; };
  18. template<typename T> struct add_pointed_const<T const* const>
  19. { typedef T const* const type; };
  20. } } } // namespace
  21. #endif //#include guard