mp_rename.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef BOOST_MP11_DETAIL_MP_RENAME_HPP_INCLUDED
  2. #define BOOST_MP11_DETAIL_MP_RENAME_HPP_INCLUDED
  3. // Copyright 2015-2023 Peter Dimov.
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. //
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. #include <boost/mp11/detail/mp_defer.hpp>
  10. #include <boost/mp11/detail/mp_value.hpp>
  11. #include <boost/mp11/detail/config.hpp>
  12. namespace boost
  13. {
  14. namespace mp11
  15. {
  16. // mp_rename<L, B>
  17. namespace detail
  18. {
  19. template<class L, template<class...> class B> struct mp_rename_impl
  20. {
  21. // An error "no type named 'type'" here means that the first argument to mp_rename is not a list
  22. };
  23. template<template<class...> class L, class... T, template<class...> class B> struct mp_rename_impl<L<T...>, B>: mp_defer<B, T...>
  24. {
  25. };
  26. #if defined(BOOST_MP11_HAS_TEMPLATE_AUTO)
  27. template<template<auto...> class L, auto... A, template<class...> class B> struct mp_rename_impl<L<A...>, B>: mp_defer<B, mp_value<A>...>
  28. {
  29. };
  30. #endif
  31. } // namespace detail
  32. template<class L, template<class...> class B> using mp_rename = typename detail::mp_rename_impl<L, B>::type;
  33. // mp_apply<F, L>
  34. template<template<class...> class F, class L> using mp_apply = typename detail::mp_rename_impl<L, F>::type;
  35. // mp_apply_q<Q, L>
  36. template<class Q, class L> using mp_apply_q = typename detail::mp_rename_impl<L, Q::template fn>::type;
  37. } // namespace mp11
  38. } // namespace boost
  39. #endif // #ifndef BOOST_MP11_DETAIL_MP_RENAME_HPP_INCLUDED