meta.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Boost.TypeErasure library
  2. //
  3. // Copyright 2018 Steven Watanabe
  4. //
  5. // Distributed under the Boost Software License Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // $Id$
  10. #ifndef BOOST_TYPE_ERASURE_DETAIL_META_HPP_INCLUDED
  11. #define BOOST_TYPE_ERASURE_DETAIL_META_HPP_INCLUDED
  12. #include <boost/config.hpp>
  13. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
  14. !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && \
  15. /* MSVC 14.0 breaks down in the template alias quagmire. */ \
  16. !BOOST_WORKAROUND(BOOST_MSVC, <= 1900)
  17. #define BOOST_TYPE_ERASURE_USE_MP11
  18. #include <boost/mp11/list.hpp>
  19. #include <boost/mp11/map.hpp>
  20. #include <boost/mp11/set.hpp>
  21. #include <boost/mp11/algorithm.hpp>
  22. #include <boost/mp11/function.hpp>
  23. #include <boost/mp11/mpl.hpp>
  24. namespace boost {
  25. namespace type_erasure {
  26. namespace detail {
  27. struct mp11_list_inserter
  28. {
  29. template<class L, class T>
  30. using apply = ::boost::mpl::identity< ::boost::mp11::mp_push_back<L, T> >;
  31. };
  32. template<class T>
  33. struct make_mp_list_impl
  34. {
  35. typedef typename ::boost::mpl::fold<
  36. T,
  37. ::boost::mp11::mp_list<>,
  38. ::boost::type_erasure::detail::mp11_list_inserter
  39. >::type type;
  40. };
  41. template<class... T>
  42. struct make_mp_list_impl< ::boost::mp11::mp_list<T...> >
  43. {
  44. typedef ::boost::mp11::mp_list<T...> type;
  45. };
  46. template<class T>
  47. using make_mp_list = typename make_mp_list_impl<T>::type;
  48. template<bool>
  49. struct eval_if_impl;
  50. template<>
  51. struct eval_if_impl<true>
  52. {
  53. template<template<class...> class T, template<class...> class F, class... A>
  54. using apply = T<A...>;
  55. };
  56. template<>
  57. struct eval_if_impl<false>
  58. {
  59. template<template<class...> class T, template<class...> class F, class... A>
  60. using apply = F<A...>;
  61. };
  62. template<bool B, template<class...> class T, template<class...> class F, class... A>
  63. using eval_if = typename ::boost::type_erasure::detail::eval_if_impl<B>::template apply<T, F, A...>;
  64. template<class T0, class...>
  65. using first = T0;
  66. }
  67. }
  68. }
  69. #endif
  70. #endif