You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
583B

  1. #include <exception>
  2. #include <memory>
  3. #include <type_traits>
  4. #include "make_unique.h"
  5. struct C {
  6. private:
  7. struct private_type { };
  8. C(private_type) { }
  9. int *m_i = nullptr;
  10. public:
  11. C() : C(private_type()) { m_i = new int; throw std::exception(); }
  12. ~C() { delete m_i; }
  13. C(C const&) = delete;
  14. C& operator=(C const&) = delete;
  15. };
  16. struct D {
  17. std::unique_ptr<int> m_i;
  18. D() : m_i(std::make_unique<int>()) { m_i = std::make_unique<int>(); throw std::exception(); }
  19. };
  20. int main() {
  21. try {
  22. C c;
  23. } catch (...) { }
  24. auto a = std::make_unique<int[]>(10);
  25. return 0;
  26. }