You can use reset
or the move assignment operator to assign a new value.
The problem with your statement
m_bar = std::unique_ptr<Bar, ReleaseBar>(CreateBar()); // 'ReleaseBar' is not a valid template type argument for parameter '_Dx'
is, as the error message you quote indicates, that ReleaseBar
is not a valid template argument. Earlier code uses ReleaseBar
in a way consistent with this being a function name. In the earlier code the corresponding template argument was void(*)(Bar*)
.