Introduce more CTL content

This change introduces accumulate, addressof, advance, all_of, distance,
array, enable_if, allocator_traits, back_inserter, bad_alloc, is_signed,
any_of, copy, exception, fill, fill_n, is_same, is_same_v, out_of_range,
lexicographical_compare, is_integral, uninitialized_fill_n, is_unsigned,
numeric_limits, uninitialized_fill, iterator_traits, move_backward, min,
max, iterator_tag, move_iterator, reverse_iterator, uninitialized_move_n

This change experiments with rewriting the ctl::vector class to make the
CTL design more similar to the STL. So far it has not slowed things down
to have 42 #include lines rather than 2, since it's still almost nothing
compared to LLVM's code. In fact the closer we can flirt with being just
like libcxx, the better chance we might have of discovering exactly what
makes it so slow to compile. It would be an enormous discovery if we can
find one simple trick to solving the issue there instead.

This also fixes a bug in `ctl::string(const string &s)` when `s` is big.
This commit is contained in:
Justine Tunney 2024-06-27 22:18:55 -07:00
parent 054da021d0
commit 38921dc46b
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
52 changed files with 2980 additions and 193 deletions

View file

@ -16,13 +16,10 @@
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include "ctl/string.h"
#include "ctl/vector.h"
#include "libc/mem/leaks.h"
#include <cosmo.h>
#include "ctl/string.h"
// #include <string>
// #include <vector>
// #define ctl std
@ -315,6 +312,45 @@ main()
return 69;
}
{
ctl::vector<int> A = { 1, 2, 3 };
if (A[1] != 2)
return 70;
A = { 4, 5, 6 };
if (A[1] != 5)
return 71;
}
{
ctl::vector<int> arr = { 1, 2, 3 };
auto rit = arr.rbegin();
if (*rit != 3)
return 72;
++rit;
if (*rit != 2)
return 73;
++rit;
if (*rit != 1)
return 74;
++rit;
if (rit != arr.rend())
return 75;
}
{
ctl::vector<ctl::string> A = { "hi", "theretheretheretherethere" };
if (A.size() != 2)
return 76;
if (A[0] != "hi")
return 77;
if (A[1] != "theretheretheretherethere")
return 78;
A = { "theretheretheretherethere", "hi" };
if (A[0] != "theretheretheretherethere")
return 79;
if (A[1] != "hi")
return 80;
}
CheckForMemoryLeaks();
return 0;
}