opm-simulators icon indicating copy to clipboard operation
opm-simulators copied to clipboard

fix mech extractor

Open akva2 opened this issue 9 months ago • 2 comments

Using .emplace() on vector is not a good idea. Compiler also doesn't want to use braced init for the struct for some reason, so resort to push_back().

akva2 avatar Mar 28 '25 12:03 akva2

Compiler also doesn't want to use braced init for the struct for some reason,

It will in C++20. The Entry is a POD and, before C++20, vector<>::emplace()–did you mean emplace_back()–doesn't work with PODs. It's really annoying, and it's the reason I sometimes add a banal constructor to my PODs. The rules for aggregate initialisation change in C++20 and, as a side effect, these kinds of in-place construction operations now work.

bska avatar Mar 28 '25 12:03 bska

yeah, that's what i mean. there were two problem, first i had used emplace, which obviously was wrong. the second problem is what you're describing much better than me, ie, that it is a c++20-ism (i knew it had worked in other code i did!). i could add the ctor, but since it's only a single entry and only a one-per-timestep thing I just ate the push_back.

akva2 avatar Mar 28 '25 12:03 akva2