I have a constructor as below:
Foo::Foo(std::unique_ptr<Bar> bar)
: left(bar->getLeft()),
right(bar->getRight()),
mBar(std::move(bar)) {}
And the program crashed due to bar
in left(bar->getLeft())
is nullptr
. If I use left(mBar->getLeft())
, it works fine.
So I wondered if there's any sequence point in member initial list? If not, how to know for sure if the move
statement happened or not? In another word: in this case, when to use argument and when to use member?