2 // https://en.cppreference.com/w/cpp/memory/new/operator_new
4 // https://en.cppreference.com/w/cpp/memory/new/operator_delete
6 // Some of these are only used in very special circumstances
7 // so rather then using new and delete expressions most calls
8 // here directly call the operators
14 class alignas(64) MyClass
{
27 // cppreference new number 1
28 OrdinaryClass
* oClass
= new OrdinaryClass();
29 // cppreference delete number 1
30 operator delete(oClass
);
32 // cppreference new number 2
33 OrdinaryClass
* oClass5
= new OrdinaryClass
[5];
34 // cppreference delete number 2
35 operator delete[](oClass5
);
38 // cppreference new number 3
39 MyClass
* myClass
= new MyClass();
40 // cppreference delete number 3
41 operator delete(myClass
, std::align_val_t(64U));
43 // cppreference new number 4
44 MyClass
* myClass5
= new MyClass
[5];
45 // cppreference delete number 4
46 operator delete[](myClass5
, std::align_val_t(64U));
49 oClass
= new OrdinaryClass();
50 // cppreference delete number 5
51 operator delete(oClass
, sizeof(OrdinaryClass
));
53 oClass5
= new OrdinaryClass
[5];
54 // cppreference delete number 6
55 operator delete[](oClass5
, sizeof(OrdinaryClass
)*5);
57 // sized aligned versions
58 myClass
= new MyClass();
59 // cppreference delete number 7
60 operator delete(myClass
, sizeof(*myClass
), std::align_val_t(64U));
62 myClass5
= new MyClass
[5];
63 // cppreference delete number 8
64 operator delete [](myClass5
, sizeof(*myClass
)*5, std::align_val_t(64U));
68 // cppreference new number 5
69 oClass
= new (std::nothrow
) OrdinaryClass
;
72 // cppreference new number 6
73 oClass5
= new (std::nothrow
) OrdinaryClass
[5];
76 // cppreference new number 7
77 myClass
= new (std::nothrow
) MyClass
;
80 // cppreference new number 8
81 myClass5
= new (std::nothrow
) MyClass
[5];