This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/86852] map and unordered_map wrong deduction guides for inilializer_list
- From: "mickey.veksler at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 04 Aug 2018 12:29:42 +0000
- Subject: [Bug libstdc++/86852] map and unordered_map wrong deduction guides for inilializer_list
- Auto-submitted: auto-generated
- References: <bug-86852-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86852
--- Comment #3 from Michael Veksler <mickey.veksler at gmail dot com> ---
I agree that this is a ridiculous example. That's why there should be an
official DR to it. It is a bad idea to have each compiler, do a different thing
-- that's why there is a C++ standard. clang are sticking to the standard, so
code that compiles under clang does not compile under gcc and vice versa.
As you mention, there is https://cplusplus.github.io/LWG/issue3025 ,
but even if this proposal is accepted things are still too brittle in libstd++:
std::unordered_map m{{1,2}, {3,4}} does not work, and forcing
std::unordered_map m{std::pair{1,2}, {3,4}} is counterintuitive.
Worse:
std::unordered_map<int,int> m(
std::initializer_list<std::pair<int, int>>{
{1, 2}, {2, 3}});
does not work, which means that:
std::unordered_map m(
std::initializer_list<std::pair<int, int>>{
{1, 2}, {2, 3}});
does not work either.
It took me some time to find the right combination that makes this work, which
you mentioned above. I have seen other struggle with this, so it is not just
me. The current way GCC does is not very intuitive.