debug_destroy_informer.h 765 B

1234567891011121314151617181920212223242526272829303132333435
  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. #ifdef _DEBUG
  8. #pragma once
  9. #include <iostream>
  10. template <typename T>
  11. class PrintDead : public T {
  12. public:
  13. template <typename... Args>
  14. PrintDead(Args&&... args) : T(std::forward<Args>(args)...) {}
  15. ~PrintDead() {
  16. std::cout
  17. << "\033[32m" // Green.
  18. << "Instance of class "
  19. << typeid(T).name()
  20. << " is dead!"
  21. << "\033[0m"
  22. << std::endl;
  23. }
  24. };
  25. // #include "base/debug_destroy_informer.h"
  26. // Usage: std::make_shared<PrintDead<QSvgRenderer>>(...);
  27. // Usage: PrintDead<QSvgRenderer>(...);
  28. #endif // _DEBUG