Add more CTL content

This commit is contained in:
Justine Tunney 2024-06-28 19:07:35 -07:00
parent 38921dc46b
commit 021c53ba32
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
56 changed files with 1747 additions and 298 deletions

View file

@ -16,7 +16,7 @@
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include "ctl/type_traits.h"
#include "ctl/is_same.h"
#include "ctl/unique_ptr.h"
#include "libc/mem/leaks.h"
@ -41,29 +41,30 @@ MkRaw()
return ctl::make_unique_for_overwrite<T>();
}
#undef ctl
// #undef ctl
static int g = 0;
struct SetsGDeleter
{
void operator()(auto*) const noexcept
void operator()(auto* x) const noexcept
{
++g;
delete x;
}
};
struct StatefulDeleter
{
char state;
void operator()(auto*) const noexcept
void operator()(auto* x) const noexcept
{
}
};
struct FinalDeleter final
{
void operator()(auto*) const noexcept
void operator()(auto* x) const noexcept
{
}
};
@ -99,6 +100,7 @@ struct Derived : Base
int
main()
{
{
Ptr<int> x(new int(5));
}
@ -186,9 +188,9 @@ main()
g = 0;
{
auto x = Mk<SetsGDtor>();
x.release();
delete x.release();
}
if (g)
if (g != 1)
return 13;
}
@ -224,8 +226,5 @@ main()
Ptr<Base> z(ctl::move(y));
}
// next is 18
// TODO(mrdomino): Fix memory leaks reported by MODE=dbg
// CheckForMemoryLeaks();
CheckForMemoryLeaks();
}