re: #18524 (review)
Personally I think these shouldn’t be idempotent because makes sense to call just once. For instance std::fstream::open
is not idempotent, fails if file is already opened. I’d rather fix unit tests. Just an opinion and should not prevent this change going forward.
Feel free to open a followup. If I wanted to change calling code not to use the same pointer more than once, I would change these to return bool and have calling code assert that they return true, rather having these crash on cases they can reasonably handle and making assumptions about calling code. I do find API’s like std::map’s insert/erase that are idempotent convenient for avoiding boilerplate code, so that’s another reason I like the keeping the boost behavior beyond not wanting to increase scope of this PR and not liking asserts across an api boundary