Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2f689aa
[deque] add placeholders for remaining 7 functions that
trcrsired Apr 28, 2026
b45eeb6
[deque] operator= should optimize for assign_range for deque
trcrsired Apr 28, 2026
dbb152a
[deque] other did not get written fully
trcrsired Apr 28, 2026
7898be1
[deque] remove a redundant empty line for emplace_index_decision_common
trcrsired Apr 28, 2026
6cb8f53
[deque] implement insert for many elements
trcrsired Apr 29, 2026
66cd614
[deque] erase needs some special treatment for insert
trcrsired Apr 29, 2026
8e4dfbc
[deque] add fuzzing for insert with counts
trcrsired Apr 29, 2026
cb52690
[deque] return should not be missed in erase_unchecked_impl
trcrsired Apr 29, 2026
1c0f922
[deque] shrink_to_fit not yet finished
trcrsired Apr 29, 2026
819f1cf
[deque] shrink to fit disable reallocating first
trcrsired Apr 29, 2026
ebce68f
[deque] shrink_to_fit should always update the pointers
trcrsired Apr 29, 2026
71414d6
[deque] try to fully implement shrink_to_fit
trcrsired Apr 29, 2026
5c61b74
[deque] add apis for accessing segments inside deque
trcrsired Apr 30, 2026
68dbf53
[deque] add a benchmark for segments api
trcrsired Apr 30, 2026
36ffc4e
[deque] benchmark for segments should use segs as the variable
trcrsired Apr 30, 2026
ad9905b
[deque] use if constexpr(true) instead of just macro for guarding
trcrsired Apr 30, 2026
d8a0aa1
[deque] try to implement deque resize but we would
trcrsired Apr 30, 2026
59d4341
[skip ci]try to implement reserve_back/reserve_front (unfinished)
trcrsired May 3, 2026
3a7970f
[deque] make compilation works for reserve first
trcrsired May 3, 2026
e599a1d
[deque] implementing deque reserve correctly
trcrsired May 3, 2026
97cf24e
add keep wine alive
trcrsired May 4, 2026
3239c6b
should be \n for keepwinealive
trcrsired May 4, 2026
31c711d
avoid testing keep alive
trcrsired May 4, 2026
63de418
[deque] add a resize implementation as placeholder
trcrsired May 4, 2026
9473dbc
[deque] draft for implementing resize. it is still buggy
trcrsired May 4, 2026
c76063d
[deque] reserve has not yet correctly implemented which
trcrsired May 4, 2026
2c7f745
using perr instead of print for test deque
trcrsired May 4, 2026
655f607
[deque] prevent crashing of reserve_back first
trcrsired May 6, 2026
eccb10e
scanpass.cc
trcrsired May 7, 2026
d171eb3
ignore scanpass
trcrsired May 7, 2026
e8315e4
allow cstring_view to be used directly for string but rvalue is forbi…
trcrsired May 7, 2026
a36f46f
[skip ci] even we know it has .c_str() we still require ::std::from_r…
trcrsired May 7, 2026
c86f9d4
prevent rvalue reference passed into string_view and cstring_view
trcrsired May 7, 2026
fe3ca94
[skip ci] prevent strict aliasing violation for casting to char16_t c…
trcrsired May 7, 2026
71ee4ba
[skip ci] span needs similar restrictions with ::std::from_range
trcrsired May 7, 2026
e452bd1
[skip ci] i forgot index_span. they should all use from_range
trcrsired May 7, 2026
e3acb08
[skip ci]add from_range paramters to index_span and span too
trcrsired May 7, 2026
7e87862
[skip ci] scan pass avoid C style cast
trcrsired May 7, 2026
94d0f3c
[skip ci] scanpass uses std::addressof and avoid &
trcrsired May 7, 2026
007e05e
avoid using template<typename T> in the code
trcrsired May 7, 2026
b8905d4
[skip ci] avoid & we use ::std::addressof
trcrsired May 7, 2026
c809f07
[skip ci] avoid ln when we ends it with literals
trcrsired May 7, 2026
fc2846b
[deque] try to finish reserve and resize
trcrsired May 8, 2026
9327fe7
[deque] no need use if for nb -= for front only for back
trcrsired May 8, 2026
9daea33
[deque] segments apis just use end it for implementation
trcrsired May 8, 2026
98dca2d
[deque] reimplement empty back logic
trcrsired May 9, 2026
1ac9151
[deque] implement assign_range
trcrsired May 9, 2026
341e5f7
[deque] try to add fuzzing for deque resize
trcrsired May 9, 2026
e26ef55
[deque] try to solve the issue for CI compilation
trcrsired May 9, 2026
fa42187
[deque] compilation failure
trcrsired May 9, 2026
51aeb04
[deque] reserve should avoid front_block issue
trcrsired May 9, 2026
5cc37ae
try to add conditional_zero apis
trcrsired May 14, 2026
9c9b82c
[allocator] try to fix one issue for adpaters here
trcrsired May 14, 2026
b735ca4
[allocator] try to implement conditional_zero
trcrsired May 14, 2026
2f18f15
[allocator] some puts alignments in the wrong order
trcrsired May 14, 2026
71bc687
add claude.md
trcrsired May 14, 2026
caf1b1f
claude
trcrsired May 14, 2026
1509ffb
[deque] try to seperate the code from the common one
trcrsired May 14, 2026
b791701
[deque] correctly implement fuzz_deque_resize
trcrsired May 14, 2026
b63267c
[deque] benchmark add std_vec as a reference
trcrsired May 14, 2026
e0bfd41
[decay] remove claude slop code
trcrsired May 14, 2026
0ec67c2
[deque] controller_ is missing for a variable
trcrsired May 14, 2026
db3810e
[deque] has no member named ‘curr_ptr_ptr’
trcrsired May 14, 2026
a7e3b28
[skip ci][deque] benchmark needs std_vec one
trcrsired May 14, 2026
a5c38ed
[skip ci][deque]benchmark should be overwrite. the i misesed
trcrsired May 14, 2026
2068e55
Merge remote-tracking branch 'parent/next' into next
trcrsired May 14, 2026
ea31ea1
[deque] deque assign
trcrsired May 14, 2026
e53ec8e
[deque] add fuzzings
trcrsired May 14, 2026
627e4d7
[deque] fuzz deque trivial
trcrsired May 14, 2026
e4080dd
[deque] the rotation logic was correct but i forgot to remove the
trcrsired May 15, 2026
034b893
[deque] clear() should be executed for assign too.
trcrsired May 15, 2026
e99fdfa
[deque] allocate one more block for reserve even at front
trcrsired May 15, 2026
41b89bb
[skip ci] add some random shit implementation of deque
trcrsired May 23, 2026
f6e852b
[deque] try a new strategy for grow
trcrsired May 24, 2026
68520dc
[deque] try to implement new logic by just detecting the size
trcrsired May 24, 2026
5fc1013
[deque] remove debug_print in resize
trcrsired May 24, 2026
18bf91b
[skip ci][deque] try to implement more although still wrong
trcrsired May 25, 2026
5f93301
[skip ci][deque] still false
trcrsired May 25, 2026
d4dfe83
[deque] incorrectly commented out code causing crash
trcrsired May 27, 2026
caa345b
[deque] erase should correctly reset front_end_ptr
trcrsired May 27, 2026
b2b92a3
[deque] Rewrite fuzz_deque_nontrivial by using ::std::shared_ptr
trcrsired May 27, 2026
9c53003
[deque] remove unused variable double extra
trcrsired May 27, 2026
9bd5817
[deque] remove front_more_blocks_mod
trcrsired May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

**fast_io** is a header-only C++20 I/O library designed to replace `<iostream>` and `<cstdio>` with dramatically better performance. It makes direct system calls, bypassing intermediary layers, and uses C++20 concepts extensively for type abstraction.

## Build & Development

### Prerequisites
- C++20 compiler: GCC >= 15, Clang >= 21, or MSVC
- CMake >= 3.15

### Build Tests, Benchmarks, and Examples

```bash
# Prebuild: generate test files (only needed once)
cmake -B fast_io_prebuild -S . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On -DTESTS_PREBUILD=On
cmake --build fast_io_prebuild
./fast_io_prebuild/tests_prebuild linux # or "windows msvc"

# Build tests/examples/benchmarks
cmake -B fast_io_build -S . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=On
cmake --build fast_io_build

# Run tests
cmake --build fast_io_build --target test
```

### Run a Single Test

Tests are located under `tests/`. After building, individual test binaries are in the `fast_io_build/tests/` subdirectories. Run them directly.

### CI

GitHub Actions (`.github/workflows/c-cpp.yml`) runs:
- **Linux**: GCC with `-fsanitize=address,undefined -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Werror`
- **Windows**: MSVC with `/EHsc /W3 /WX /sdl`
- Uses Ninja generator on both platforms

## Architecture

The library uses a layered architecture:

| Layer | Header | Description |
|-------|--------|-------------|
| Concepts | `fast_io_concept.h` | C++20 concepts for I/O device abstraction |
| Core | `fast_io_core.h` | Freestanding-capable: bit ops, integer formatting, codecvt, SIMD |
| Freestanding | `fast_io_freestanding.h` | Adds buffered I/O, decorators, serializers, transcoders |
| Hosted | `fast_io_hosted.h` | Full features: platform abstractions, filesystem, threads, process/IPC |
| Main | `fast_io.h` | Entry point: combines hosted + legacy stream interop |

### Key Directories

- `include/fast_io_core_impl/` — Core implementation internals (operations: `printimpl`, `readimpl`, `writeimpl`, `transmitimpl`, `transcodeimpl`)
- `include/fast_io_hosted/` — Hosted platform implementations (console, filesystem, mmap, threads, process)
- `include/fast_io_freestanding_impl/` — Buffered I/O, decorators, scanners, serialization
- `include/fast_io_legacy_impl/` — FILE*/streambuf hacks for glibc, MSVCRT, UCRT, MUSL, BSD libc, libstdc++, libc++, MSVC STL
- `include/fast_io_dsal/` — Data Structure Abstraction Layer (vector, string, deque, list, etc.)
- `include/fast_io_driver/` — Third-party integrations (Boost.Asio, OpenSSL, Qt, MFC, LLVM, Python, zlib)
- `include/fast_io_crypto/` — SHA-1, SHA-256, SHA-512, HMAC, ciphers
- `share/fast_io/` — C++20 module files

### Header Organization

- `fast_io.h` — Primary entry point (most common include)
- `fast_io_device.h` — Device types (files, pipes, sockets)
- `fast_io_crypto.h` — Cryptographic hash functions
- `fast_io_i18n.h` — Internationalization/locale
- `fast_io_legacy.h` — Legacy C/C++ stream compatibility

### fast_io's 6 layers of files from bottom to top
- wine_file
- nt_file
- win32_file
- posix_file
- c_file
- filebuf_file

From bottom to top we do a move.
From top to bottom we do a static cast to the
lower level of io_observer.

## Testing

- Tests are organized into numbered categories under `tests/`
- `.test_prop.toml` controls which tests run per platform/compiler
- Test files are generated by `tests/0000.tests_prebuild/gentests.cc`
- Some tests are ignored for incomplete features or platform requirements

## Benchmarking

Benchmarks live under `benchmark/` with numbered categories (integer I/O, floating-point, file I/O, concat, containers, codecvt, syscalls, etc.). Many have standalone `Makefile`s using `clang++ -Ofast -march=native -std=c++20` with precompiled headers.

## Style & Conventions

- `.clang-format` and `.editorconfig` are present — format code before committing
- This is a header-only library — no `.cpp` source files in `include/`
- The library targets both freestanding (no OS) and hosted environments
- Consistent error handling via exceptions only (no `std::error_code` or `std::system_error`)
- License: Anti-Tivo License (ATL) v1.0
2 changes: 1 addition & 1 deletion benchmark/0011.containers/deque/0001.push_back/fast_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ int main()
sum += e;
}
}
::fast_io::io::perrln("sum=",sum);
::fast_io::io::perrln("sum=", sum);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <fast_io.h>
#include <fast_io_driver/timer.h>
#include <fast_io_dsal/deque.h>

int main()
{
fast_io::timer tm(u8"fast_io::deque resize_for_overwrite");
fast_io::deque<std::size_t> deq;
constexpr std::size_t n{100000000};
{
fast_io::timer tm1(u8"push_back");
deq.resize(n, ::fast_io::for_overwrite);
::std::size_t idx{};
for (::std::size_t i{}, segs{deq.segments_count()}; i != segs; ++i)
{
for (auto &e : deq.nth_segment(i))
{
e = idx;
++idx;
}
}
}
::std::size_t sum{};
{
fast_io::timer tm1(u8"loop");
for (::std::size_t i{}, segs{deq.segments_count()}; i != segs; ++i)
{
for (auto const e : deq.const_nth_segment(i))
{
sum += e;
}
}
}
::fast_io::io::perrln("sum=", sum);
}
29 changes: 29 additions & 0 deletions benchmark/0011.containers/deque/0001.push_back/fast_io_segments.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <fast_io.h>
#include <fast_io_driver/timer.h>
#include <fast_io_dsal/deque.h>

int main()
{
fast_io::timer tm(u8"fast_io::deque segments");
fast_io::deque<std::size_t> deq;
constexpr std::size_t n{100000000};
{
fast_io::timer tm1(u8"push_back");
for (std::size_t i{}; i != n; ++i)
{
deq.push_back(i);
}
}
::std::size_t sum{};
{
fast_io::timer tm1(u8"loop");
for (::std::size_t i{}, segs{deq.segments_count()}; i != segs; ++i)
{
for (auto const e : deq.const_nth_segment(i))
{
sum += e;
}
}
}
::fast_io::io::perrln("sum=", sum);
}
4 changes: 2 additions & 2 deletions benchmark/0011.containers/deque/0001.push_back/std.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main()
for (auto const e : deq)
{
sum += e;
}
}
}
::fast_io::io::perrln("sum=",sum);
::fast_io::io::perrln("sum=", sum);
}
26 changes: 26 additions & 0 deletions benchmark/0011.containers/deque/0001.push_back/std_vec.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <fast_io.h>
#include <fast_io_driver/timer.h>
#include <vector>

int main()
{
fast_io::timer tm(u8"std::vector");
std::vector<std::size_t> vec;
constexpr std::size_t n{100000000};
{
fast_io::timer tm1(u8"push_back");
for (std::size_t i{}; i != n; ++i)
{
vec.push_back(i);
}
}
::std::size_t sum{};
{
fast_io::timer tm1(u8"loop");
for (auto const e : vec)
{
sum += e;
}
}
::fast_io::io::perrln("sum=", sum);
}
6 changes: 6 additions & 0 deletions examples/.test_prop.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ ignore = true
["0040.wifianalyzer"]
ignore = true

["0041.keepwinealive"]
ignore = true

["0042.scn_ip_port"]
interactive = true

["0043.scanwinprocesspasswords"]
ignore = true
12 changes: 12 additions & 0 deletions examples/0041.keepwinealive/keepwinealive.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<fast_io.h>
#define NOMINMAX 1
#define _WIN32_LEAN_AND_MEAN
#include<windows.h>
#undef min
#undef max

int main()
{
::fast_io::io::perrln("keep wine alive: ", utc(::fast_io::posix_clock_gettime(::fast_io::posix_clock_id::realtime)));
WaitForSingleObject(GetCurrentProcess(), INFINITE);
}
Loading
Loading