In the Guidelines Support Library there is a class called final_action
(essentially the well known ScopeGuard). There are 2 free-standing convenience functions to generate this templated class:
// finally() - convenience function to generate a final_action
template <class F>
inline final_action<F> finally(const F& f) noexcept
{
return final_action<F>(f);
}
template <class F>
inline final_action<F> finally(F&& f) noexcept
{
return final_action<F>(std::forward<F>(f));
}
What is the need for the first one? If we only had the second one (using the forwarding , a.k.a. universal, references) wouldn't it do the same thing?
Aucun commentaire:
Enregistrer un commentaire