mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-15 07:01:18 +02:00
Define Destroy_ptr
This commit is contained in:
@@ -688,6 +688,22 @@ make_movable_with_deleter(const Deleter &d, Args&&... args)
|
|||||||
return movable_ptr_with_deleter<T, Deleter>(safenew T(std::forward<Args>(args)...), d);
|
return movable_ptr_with_deleter<T, Deleter>(safenew T(std::forward<Args>(args)...), d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A deleter class to supply the second template parameter of unique_ptr for
|
||||||
|
* classes like wxWindow that should be sent a message called Destroy rather
|
||||||
|
* than be deleted directly
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
struct Destroyer {
|
||||||
|
void operator () (T *p) const { if (p) p->Destroy(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* a convenience for using Destroyer
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
using Destroy_ptr = std::unique_ptr<T, Destroyer<T>>;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "finally" as in The C++ Programming Language, 4th ed., p. 358
|
* "finally" as in The C++ Programming Language, 4th ed., p. 358
|
||||||
* Useful for defining ad-hoc RAII actions.
|
* Useful for defining ad-hoc RAII actions.
|
||||||
|
Reference in New Issue
Block a user