File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ struct optional_deleter
5151 * contain a reference (and thus not delete its content
5252 * on destruction).
5353 *
54+ * The default is an owning pointer, so that it can be used
55+ * just like a plain std::unique_ptr. It should be trivial to
56+ * switch to a plain one later, if the non-owning part is not
57+ * used any longer.
58+ *
5459 * \note Think twice before using this!
5560 *
5661 * It's mostly meant for cases, where FairRoot has a public API
Original file line number Diff line number Diff line change @@ -54,6 +54,17 @@ TEST_CASE("maybe_owning_ptr")
5454 REQUIRE (analyzer.destructed == 1 );
5555 REQUIRE (analyzer.was_destructed (' A' ));
5656 }
57+ SECTION (" unique_ptr style initialize and go out of scope" )
58+ {
59+ {
60+ MaybeOwning other{item_a.release ()};
61+ REQUIRE (!item_a);
62+ REQUIRE (other);
63+ REQUIRE (analyzer.destructed == 0 );
64+ }
65+ REQUIRE (analyzer.destructed == 1 );
66+ REQUIRE (analyzer.was_destructed (' A' ));
67+ }
5768 SECTION (" Pass ownership and go out of scope" )
5869 {
5970 {
You can’t perform that action at this time.
0 commit comments