custom_delete.h 441 B

123456789101112131415161718192021
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. namespace base {
  9. template <auto fn>
  10. struct custom_delete {
  11. template <typename T>
  12. constexpr void operator()(T* value) const {
  13. if (value) {
  14. fn(value);
  15. }
  16. }
  17. };
  18. } // namespace base