Мигрирую тут своё барахлишко с -std=c++20
на -std=c++23
, и всё чистенько, кроме одного затыка:
#include <unordered_map>
class C {};
int main() {
C c;
std::unordered_map<C*, int> m;
m.insert({&c, 0}); // no matching function for call to 'get'
return 0;
}
C++20 компилял это нормально, C++23 ругается на &c
. Что поменяли, чего ей надо?
Вот так работает, но это ж как-то длинно и глупо:
m.insert(std::pair{&c, "hello"});
UPD: «Но действительность ещё кошмарней.» (c)
#include <regex>
int main() {
static std::regex rColor {"^#?[0-9A-Fa-f]{6}$"};
return 0;
}
$ clang -std=c++23 -c try.cpp
In file included from try.cpp:1:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/regex:40:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bitset:52:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/string:67:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/memory_resource.h:41:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/uses_allocator_args.h:39:
/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<const long &>::__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<const long &>::__convertible_from_tuple_like<const long &>' 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/bits/stl_map.h:514:38: note: while substituting deduced template arguments into function template 'tuple' [with _UTuple = const key_type &]
514 | std::tuple<const key_type&>(__k),
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex_automaton.tcc:207:7: note: in instantiation of member function 'std::map<long, long>::operator[]' requested here
207 | __m[__u] = __id;
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex_compiler.tcc:241:24: note: in instantiation of member function 'std::__detail::_StateSeq<std::regex_traits<char>>::_M_clone' requested here
241 | __e._M_append(__r._M_clone());
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex_compiler.tcc:135:17: note: (skipping 2 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
135 | while (this->_M_quantifier())
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex_compiler.tcc:91:13: note: in instantiation of member function 'std::__detail::_Compiler<std::regex_traits<char>>::_M_alternative' requested here
91 | this->_M_alternative();
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex_compiler.tcc:76:13: note: in instantiation of member function 'std::__detail::_Compiler<std::regex_traits<char>>::_M_disjunction' requested here
76 | this->_M_disjunction();
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex.h:809:34: note: in instantiation of member function 'std::__detail::_Compiler<std::regex_traits<char>>::_Compiler' requested here
809 | __detail::_Compiler<_Rx_traits> __c(__first, __last, _M_loc, __f);
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/regex.h:473:9: note: in instantiation of member function 'std::basic_regex<char>::_M_compile' requested here
473 | { _M_compile(__p, __p + _Rx_traits::length(__p), __f); }
| ^
try.cpp:14:26: note: in instantiation of member function 'std::basic_regex<char>::basic_regex' requested here
14 | static const std::regex shmNameRegex {"^/[^/]{1,254}$"};
| ^
/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 'const long'
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 'const tuple<_Elements...>' against 'const long'
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 'const long'
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 'const tuple<_Elements...>' against 'const long'
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:138:5: note: candidate template ignored: could not match 'array<_Tp, _Nm>' against 'const long'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:142:5: note: candidate template ignored: could not match 'array<_Tp, _Nm>' against 'const long'
142 | get(array<_Tp, _Nm>&&) noexcept;
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:146:5: note: candidate template ignored: could not match 'const array<_Tp, _Nm>' against 'const long'
146 | get(const array<_Tp, _Nm>&) noexcept;
| ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/stl_pair.h:150:5: note: candidate template ignored: could not match 'const array<_Tp, _Nm>' against 'const long'
150 | get(const array<_Tp, _Nm>&&) 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 'const long'
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 'const long'
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 'const pair<_Tp1, _Tp2>' against 'const long'
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 'const pair<_Tp1, _Tp2>' against 'const long'
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/bits/ranges_util.h:444:5: note: candidate template ignored: could not match 'const subrange<_It, _Sent, _Kind>' against 'const long'
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 'const long'
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
| ^
1 error generated.