mp_map_find.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED
  2. #define BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED
  3. // Copyright 2015 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/utility.hpp>
  10. namespace boost
  11. {
  12. namespace mp11
  13. {
  14. // mp_map_find
  15. namespace detail
  16. {
  17. template<class M, class K> struct mp_map_find_impl;
  18. template<template<class...> class M, class... T, class K> struct mp_map_find_impl<M<T...>, K>
  19. {
  20. using U = mp_inherit<mp_identity<T>...>;
  21. template<template<class...> class L, class... U> static mp_identity<L<K, U...>> f( mp_identity<L<K, U...>>* );
  22. static mp_identity<void> f( ... );
  23. using V = decltype( f((U*)0) );
  24. using type = typename V::type;
  25. };
  26. } // namespace detail
  27. template<class M, class K> using mp_map_find = typename detail::mp_map_find_impl<M, K>::type;
  28. } // namespace mp11
  29. } // namespace boost
  30. #endif // #ifndef BOOST_MP11_DETAIL_MP_MAP_FIND_HPP_INCLUDED