-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Description
By debugging I found that calling emplace constructs the object and std::move
s it. This is not consistent with std::optional
. I'm using a std::vector<nonstd::optional<OBJ>>
object named cms
and OBJ
has a constructor taking three arguments. In this code:
if (not cms[index]) {
cms[index].emplace(e, p, m);
}
...the destructor of OBJ
is called unexpectedly because here:
+ 46 at optional.hpp:763
760 void emplace( Args&&... args )
761 {
762 *this = nullopt;
-> 763 initialize( T( std::forward<Args>(args)...) );
764 }
765
OBJ
is apparently created and destroyed temporarily.
Metadata
Metadata
Assignees
Labels
No labels