22 lines
493 B
C++
22 lines
493 B
C++
module;
|
|
|
|
export module utils.memory;
|
|
|
|
export namespace utils
|
|
{
|
|
/**
|
|
* Template to generate deleters for `std::unique_ptr` from functions, e.g. to free SDL resources.
|
|
*
|
|
* @tparam delete_func Function that takes a pointer to a resource and deletes the resource.
|
|
*/
|
|
template <auto delete_func>
|
|
struct FuncDeleter
|
|
{
|
|
template <typename T>
|
|
constexpr void operator()(T* ptr) const noexcept
|
|
{
|
|
delete_func(ptr);
|
|
}
|
|
};
|
|
}
|