martinus / unordered_dense

A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion
MIT License
898 stars 72 forks source link

[BUG] Broken in C++23 with clang-17 / libstdc++-14 #119

Open jcelerier opened 4 months ago

jcelerier commented 4 months ago

Describe the bug Simple code fails to build in C++23 mode. Boost flat_map has the same issue : https://github.com/boostorg/container/issues/282

To Reproduce

#include <ankerl/unordered_dense.h>

int main() {
  ankerl::unordered_dense::map<int, int> f;
  f[0];
}
$ clang++ -std=c++23 foo.cpp -I unordered_dense/include
In file included from foo.cpp:1:
In file included from unordered_dense/include/ankerl/unordered_dense.h:84:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/functional:53:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:956:36: error: no matching function for call to 'get'
  956 |             return __convertible<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
      |                                           ^~~~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:955:11: note: in instantiation of function template specialization 'std::tuple<int &&>::__convertible_from_tuple_like()::(anonymous class)::operator()<0UL>' requested here
  955 |           return []<size_t... _Is>(index_sequence<_Is...>) {
      |                  ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:1136:22: note: in instantiation of function template specialization 'std::tuple<int &&>::__convertible_from_tuple_like<int>' requested here
 1136 |         constexpr explicit(!__convertible_from_tuple_like<_UTuple>())
      |                             ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/tuple:2651:36: note: while substituting deduced template arguments into function template 'tuple' [with _UTuple = int]
 2651 |     { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
      |                                    ^
unordered_dense/include/ankerl/unordered_dense.h:1109:46: note: in instantiation of function template specialization 'std::forward_as_tuple<int>' requested here
 1109 |                                         std::forward_as_tuple(std::forward<K>(key)),
      |                                              ^
unordered_dense/include/ankerl/unordered_dense.h:1579:16: note: in instantiation of function template specialization 'ankerl::unordered_dense::detail::table<int, int, ankerl::unordered_dense::hash<int>, std::equal_to<int>, std::allocator<std::pair<int, int>>, ankerl::unordered_dense::bucket_type::standard, false>::do_try_emplace<int>' requested here
 1579 |         return do_try_emplace(std::move(key), std::forward<Args>(args)...);
      |                ^
unordered_dense/include/ankerl/unordered_dense.h:1751:16: note: in instantiation of function template specialization 'ankerl::unordered_dense::detail::table<int, int, ankerl::unordered_dense::hash<int>, std::equal_to<int>, std::allocator<std::pair<int, int>>, ankerl::unordered_dense::bucket_type::standard, false>::try_emplace<int, true>' requested here
 1751 |         return try_emplace(std::move(key)).first->second;
      |                ^
foo.cpp:5:4: note: in instantiation of function template specialization 'ankerl::unordered_dense::detail::table<int, int, ankerl::unordered_dense::hash<int>, std::equal_to<int>, std::allocator<std::pair<int, int>>, ankerl::unordered_dense::bucket_type::standard, false>::operator[]<int, true>' requested here
    5 |   f[0];
      |    ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:122:5: note: candidate template ignored: could not match 'tuple<_Elements...>' against 'int'
  122 |     get(tuple<_Elements...>& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:126:5: note: candidate template ignored: could not match 'tuple<_Elements...>' against 'int'
  126 |     get(const tuple<_Elements...>& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:130:5: note: candidate template ignored: could not match 'tuple<_Elements...>' against 'int'
  130 |     get(tuple<_Elements...>&& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:134:5: note: candidate template ignored: could not match 'tuple<_Elements...>' against 'int'
  134 |     get(const tuple<_Elements...>&& __t) noexcept;
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1250:5: note: candidate template ignored: could not match 'pair<_Tp1, _Tp2>' against 'int'
 1250 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1255:5: note: candidate template ignored: could not match 'pair<_Tp1, _Tp2>' against 'int'
 1255 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1260:5: note: candidate template ignored: could not match 'pair<_Tp1, _Tp2>' against 'int'
 1260 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1265:5: note: candidate template ignored: could not match 'pair<_Tp1, _Tp2>' against 'int'
 1265 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/array:390:5: note: candidate template ignored: could not match 'array<_Tp, _Nm>' against 'int'
  390 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/array:399:5: note: candidate template ignored: could not match 'array<_Tp, _Nm>' against 'int'
  399 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/array:408:5: note: candidate template ignored: could not match 'array<_Tp, _Nm>' against 'int'
  408 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/array:417:5: note: candidate template ignored: could not match 'array<_Tp, _Nm>' against 'int'
  417 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/ranges_util.h:444:5: note: candidate template ignored: could not match 'subrange<_It, _Sent, _Kind>' against 'int'
  444 |     get(const subrange<_It, _Sent, _Kind>& __r)
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/ranges_util.h:455:5: note: candidate template ignored: could not match 'subrange<_It, _Sent, _Kind>' against 'int'
  455 |     get(subrange<_It, _Sent, _Kind>&& __r)
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1272:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1272 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1277:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1277 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1282:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1282 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1287:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1287 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1292:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1292 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1297:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1297 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1302:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1302 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:1307:5: note: candidate template ignored: invalid explicitly-specified argument for template parameter '_Tp'
 1307 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^

System (please complete the following information):