Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

constructing unordered_set using initializer list

user2038339Mar 20 2015 — edited Mar 20 2015

When I construct an unordered_set using an initializer list of three or more items, or one, Solstudio 12.4 compiles without complaint:

unordered_set<string> sam({"a", "b", "c"});

However, if I reduce the number of items in the initializer list to exactly 2, the compiler complains

unordered_set<string> bob({"a", "b"});

Error: Overloading ambiguity between

"std::unordered_set, std::equal_to, std::allocator>::unordered_set( std::initializer_list, unsigned long, const std::hash&, const std::equal_to&, const std::allocator&)" and

"std::unordered_set, std::equal_to, std::allocator>::unordered_set( std::unordered_set, std::equal_to, std::allocator>&&)". 1 Error(s) detected.

I'm pretty sure I can cast this error away but I'm curious about why the compiler chokes for this case. Any ideas?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2015
Added on Mar 20 2015
1 comment
597 views