I'm updating some of our old code to use C++11 features in place of boost equivalents. However not everything is a simple namespace replacement like unordered containers and smart pointers.
For example boost::function
has methods empty()
and clear()
but std::function
does not.
There is an operator()
defined for std::function
that I've been using to replace empty()
references but what should I use to replace clear()
references?
I've considered using the std::function
assignment operator and assigning nullptr
to clear it but I'm worried that might have unintentional side affects of clearing not only the underlying function but rendering the object unusable.
Obviously, the better solution would be default initialization of any reusable member function objects that way there is always a valid callback which can simply be updated with a user provided one but I'm just aiming for a direct replacement of the previous usage right now not a code review.