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.

35 lines
583 B

#include <exception>
#include <memory>
#include <type_traits>
#include "make_unique.h"
struct C {
private:
struct private_type { };
C(private_type) { }
int *m_i = nullptr;
public:
C() : C(private_type()) { m_i = new int; throw std::exception(); }
~C() { delete m_i; }
C(C const&) = delete;
C& operator=(C const&) = delete;
};
struct D {
std::unique_ptr<int> m_i;
D() : m_i(std::make_unique<int>()) { m_i = std::make_unique<int>(); throw std::exception(); }
};
int main() {
try {
C c;
} catch (...) { }
auto a = std::make_unique<int[]>(10);
return 0;
}