CTL: utility.h, use ctl::swap in string (#1227)

* Add ctl utility.h

Implements forward, move, swap, and declval. This commit also adds a def
for nullptr_t to cxx.inc. We need it now because the CTL headers stopped
including anything from libc++, so we no longer get their basic types.

* Use ctl::swap in string

The STL spec says that swap is located in the string_view header anyawy.
Performance-wise this is a noop, but it’s slightly cleaner.
This commit is contained in:
Steven Dee (Jōshin) 2024-06-18 22:00:59 -07:00 committed by GitHub
parent a795017416
commit 9a5a13854d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 117 additions and 46 deletions

View file

@ -18,7 +18,7 @@
#include "ctl/unique_ptr.h"
#include <type_traits>
#include <__type_traits/is_same.h>
#include "libc/runtime/runtime.h"
@ -32,7 +32,7 @@ template<typename T, typename... Args>
Ptr<T>
Mk(Args&&... args)
{
return ctl::make_unique<T, Args...>(std::forward<Args>(args)...);
return ctl::make_unique<T, Args...>(ctl::forward<Args>(args)...);
}
template<typename T>
@ -161,7 +161,7 @@ main()
// shouldn't compile
x = y;
#endif
x = std::move(y);
x = ctl::move(y);
if (g != 1)
return 10;
if (y)