Bug 1252195 - part 1 - implement UniqueFreePtr; r=Waldo

Just like UniquePtr<T>, except that we're going to delete the allocated
memory with |free()|.
This commit is contained in:
Nathan Froyd 2016-02-29 10:29:13 -05:00
parent f568275042
commit d1c83df637

View File

@ -37,6 +37,21 @@ template<typename T, typename... Args>
typename detail::UniqueSelector<T>::KnownBound
MakeUniqueFallible(Args&&... aArgs) = delete;
namespace detail {
template<typename T>
struct FreePolicy
{
void operator()(const void* ptr) {
free(const_cast<void*>(ptr));
}
};
} // namespace detail
template<typename T>
using UniqueFreePtr = UniquePtr<T, detail::FreePolicy<T>>;
} // namespace mozilla
#endif // mozilla_UniquePtrExtensions_h