-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<vector>: Cannot resize
/reserve
an instance of std::vector<std::unordered_map<int, move_only_type>>
#5084
Comments
Arguably a duplicate of #1036. It's unfortunate that
so copy construction is attempted, which cause hard error (seems to be UB in standard wording). |
Given the existence of types whose copyability is indeterminate - in the Standard Library itself! - I think the requirement in [vector.modifiers]/2 that:
is unimplementable. I'd greatly prefer that we ignore this requirement by having vector reallocation always move instead of copy and submit an LWG issue to get the requirement fixed. Sometimes moving when we "should" copy is a much smaller bug than I'll mark this
decision needed
|
We talked about this at the weekly maintainer meeting and we believe this merits a Library Evolution issue. We would like to see @CaseyCarter's suggestion adopted -
For other implementations (where their container-internal sentinel nodes don't result in throwing moves), this issue still theoretically impacts them, but a user has to bring them a type with a throwing move ctor (which can be fairly easily obtained - just forget to mention |
Describe the bug
vector
andunordered_map
seem to interact in an unexpected way. I canresize
avector
of move-only type, I canemplace
into anunordered_map
of move-onlymapped_type
, but MS-STL won't allow me toresize
avector
ofunordered_map
of move-onlymapped_type
.Command-line test case
Expected behavior
Have the code compile, like libstdc++ allows this.
Versions
Visual Studio
MSVC
STL
Additional context
Obligatory Godbolt
The text was updated successfully, but these errors were encountered: