Skip to content

Commit 1a99027

Browse files
committed
Add an alternative implementation of mp_map_find for GCC 14+. Fixes #106.
1 parent f8ee448 commit 1a99027

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

include/boost/mp11/detail/mp_map_find.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
#include <boost/mp11/utility.hpp>
1212
#include <boost/mp11/detail/config.hpp>
1313

14+
#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, >= 140000 )
15+
16+
#include <boost/mp11/detail/mp_list.hpp>
17+
#include <boost/mp11/detail/mp_append.hpp>
18+
#include <boost/mp11/detail/mp_front.hpp>
19+
20+
#endif
21+
1422
#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1930 )
1523

1624
// not exactly good practice, but...
@@ -26,6 +34,30 @@ namespace boost
2634
namespace mp11
2735
{
2836

37+
#if BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, >= 140000 )
38+
39+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120161
40+
41+
namespace detail
42+
{
43+
44+
template<class M, class K> struct mp_map_find_impl;
45+
46+
template<template<class...> class M, class... T, class K> struct mp_map_find_impl<M<T...>, K>
47+
{
48+
template<class U> using _f = mp_if<std::is_same<mp_front<U>, K>, mp_list<U>, mp_list<>>;
49+
50+
using _l = mp_append<_f<T>..., mp_list<void>>;
51+
52+
using type = mp_front<_l>;
53+
};
54+
55+
} // namespace detail
56+
57+
template<class M, class K> using mp_map_find = typename detail::mp_map_find_impl<M, K>::type;
58+
59+
#else
60+
2961
// mp_map_find
3062
namespace detail
3163
{
@@ -81,6 +113,8 @@ template<template<class...> class M, class... T, class K> struct mp_map_find_imp
81113

82114
template<class M, class K> using mp_map_find = typename detail::mp_map_find_impl<M, K>::type;
83115

116+
#endif
117+
84118
} // namespace mp11
85119
} // namespace boost
86120

0 commit comments

Comments
 (0)