diff --git a/docs/docs/01.helloworld/index.html b/docs/docs/01.helloworld/index.html deleted file mode 100644 index d08d2026..00000000 --- a/docs/docs/01.helloworld/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - Hello World - fast_io Documentation - - - - -
-

Hello World

- -
-

Hello World

-

- A minimal program using fast_io to print Hello World: -

-

-#include <fast_io.h>
-
-int main()
-{
-    using namespace ::fast_io::io;
-    print("Hello World\n");
-}
-
-

- By default, ::fast_io::io::print writes to C’s FILE* stdout object. - This means the output goes to the standard output stream, just like printf or - std::cout, but with safer and faster semantics. -

-

- In practice, using fast_io together with stdio or iostream - usually does not cause issues. The only problematic cases arise if code calls unusual functions - like unput, which can break assumptions because neither stdio nor - iostream guarantee consistent behavior for such operations. As long as you avoid - those unsafe edge cases, interoperability is fine. -

-
- - -
- - diff --git a/docs/docs/02.aplusb/index.html b/docs/docs/02.aplusb/index.html deleted file mode 100644 index 3d0992a4..00000000 --- a/docs/docs/02.aplusb/index.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - A + B - fast_io Documentation - - - - -
-

A + B

- -
-

Basic Input and Output

-

- A simple program that reads two integers and prints their sum. This demonstrates - scan for input and println for output: -

-

-#include <fast_io.h>
-
-using namespace fast_io::io;
-
-int main()
-{
-    std::size_t a, b;
-    scan(a, b);
-    println(a + b);
-}
-
-
- -
-

What is a Manipulator?

-

- In fast_io, a manipulator is a helper object that changes how - input or output is interpreted or formatted. Instead of relying on unsafe format strings, - manipulators make the intent explicit in the type system. -

-

- Manipulators are defined in the namespace fast_io::manipulators, which is aliased - as fast_io::mnp for convenience. They make input and output safer, more explicit, - and more portable than traditional stdio or iostream. -

-

- For example: -

- -
- -
-

Hexadecimal Manipulators

-

- fast_io provides manipulators to read and print numbers in hexadecimal. - hex_get reads input in hex, while hex and hexupper - print output in lowercase or uppercase hex respectively: -

-

-#include <fast_io.h>
-
-using namespace fast_io::io;
-
-int main()
-{
-    using namespace fast_io::mnp;
-    std::size_t a, b;
-    scan(hex_get(a), hex_get(b));
-    println(hex(a + b), " ", hexupper(a + b));
-}
-
-
- -
-

Base-N Manipulators

-

- Manipulators also support arbitrary bases from 2 to 36. Here’s an example using base 36: -

-

-#include <fast_io.h>
-
-using namespace fast_io::io;
-
-int main()
-{
-    using namespace fast_io::mnp;
-    std::size_t a, b;
-    scan(base_get<36>(a), base_get<36>(b));
-    println(base<36>(a + b));
-}
-
-
- -
-

About Manipulators

-

- fast_io defines a rich set of manipulators to control input and output formatting. - For convenience, the namespace fast_io::manipulators is aliased as fast_io::mnp. -

- -

- These manipulators make it easy to work with different numeric bases without relying on unsafe format strings. -

-
- - -
- - diff --git a/docs/docs/03.pointer/index.html b/docs/docs/03.pointer/index.html deleted file mode 100644 index b1d5bc9a..00000000 --- a/docs/docs/03.pointer/index.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - Pointers - fast_io Documentation - - - - -
-

Pointers

- -
-

Introduction

-

- In fast_io, raw pointers and iterators are not printed directly. This is a deliberate - safety choice: printing them without explicit intent can lead to undefined or inconsistent - behavior across platforms. Instead, fast_io provides a family of pointer‑related - manipulators that make the intent explicit and ensure consistent, portable formatting. -

-
- -
-

Pointer Manipulators Overview

- -
- -
-

Printing Pointers

-

- Use pointervw to print raw addresses. The format is consistent across platforms: - 0x followed by 8 hex digits on 32‑bit systems, or 16 hex digits on 64‑bit systems. -

-

-#include <fast_io.h>
-
-using namespace fast_io::io;
-
-int main()
-{
-    using namespace fast_io::mnp;
-    int x{42};
-    int *ptr{::std::addressof(x)};
-    println("Address:", pointervw(ptr));
-}
-      
-
- -
-

C‑String Manipulator

-

- To treat a char const* as a C‑string, use os_c_str. This calls - strlen or strnlen depending on overload. -

-

-#include <fast_io.h>
-
-int main()
-{
-    using namespace fast_io::io;
-    using namespace fast_io::mnp;
-    constexpr char const* ptr{"Hello\0World\n"};
-
-    println(
-        "Literal: Hello\0World\n\n"
-        "Pointer:", pointervw(ptr), "\n"
-        "os_c_str:", os_c_str(ptr), "\n"
-        "os_c_str(ptr,4):", os_c_str(ptr,4), "\n"
-        "os_c_str(ptr,10):", os_c_str(ptr,10)
-    );
-}
-      
-
- -
-

Function and Method Pointers

-

- funcvw prints the address of a free function. methodvw prints member - function pointers, including offset information for multiple inheritance cases. -

-

-#include <fast_io.h>
-#include <memory>
-
-class dummy_class { public: void dummy_method() noexcept {} };
-struct A { virtual void f() noexcept {} };
-struct B { virtual void g() noexcept {} };
-struct C : A, B {};
-
-using namespace fast_io::io;
-
-void foo(){}
-
-int main()
-{
-    using namespace fast_io::mnp;
-    void (C::*downcptr)() noexcept = &B::g;
-
-    println(
-        "funcvw(foo):", funcvw(foo), "\n"
-
-        "methodvw(&dummy_class::dummy_method):",
-        methodvw(&dummy_class::dummy_method), "\n"
-
-        "methodvw(downcptr):", methodvw(downcptr)
-    );
-}
-      
-
- -
-

Handles

-

- handlevw is used when printing operating system handles. A handle may be an - integer (POSIX file descriptor) or a pointer (Win32 HANDLE, FILE*). - handlevw adapts automatically, printing integers directly and pointers in - consistent hexadecimal format. -

-

-#include <fast_io.h>
-#include <cstdio>
-
-using namespace fast_io::io;
-
-int main()
-{
-    using namespace fast_io::mnp;
-    int fd{3};       // POSIX file descriptor
-    FILE *f{stdout};
-
-    println(
-        "POSIX fd:", handlevw(fd), "\n"
-        "FILE* handle:", handlevw(f)
-    );
-}
-      
-
- -
-

Summary

-

- Pointer‑related manipulators in fast_io make printing low‑level entities explicit, - safe, and portable. They cover raw pointers, C‑strings, free functions, member functions, - and OS handles. This design avoids the unsafe and inconsistent behavior of - stdio and iostream. -

-
- - -
- - diff --git a/docs/docs/04.fileio/index.html b/docs/docs/04.fileio/index.html deleted file mode 100644 index e68c4d5d..00000000 --- a/docs/docs/04.fileio/index.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - File I/O - fast_io Documentation - - - - -
-

File I/O

- -
-

Basic File Input and Output

-

- fast_io provides file types such as ibuf_file and obuf_file - for buffered input and output. File names can be passed as any character type, and the - os_c_str manipulator applies here as well. -

-

-#include <fast_io.h>
-#include <fast_io_device.h>
-
-int main()
-{
-    ::fast_io::ibuf_file ibf(u8"aplusb_in.txt");
-    ::fast_io::obuf_file obf(u8"aplusb_out.txt");
-    ::std::size_t a, b;
-    scan(ibf, a, b);
-    println(obf, a + b);
-}
-      
-
- -
-

Directory Files

-

- dir_file represents a directory handle. You can open files relative to a directory - using at(dir). This makes it easy to work with subdirectories and ensures - portability across platforms. -

-

-#include <fast_io.h>
-#include <fast_io_device.h>
-
-int main(int argc, char** argv)
-{
-    ::fast_io::dir_file dir(fast_io::mnp::os_c_str(argv[1]));
-    ::fast_io::obuf_file obf(at(dir), u8"hello.txt");
-    println(obf, "Hello World\n");
-
-    ::fast_io::dir_file subdir(at(dir), u8"subdir");
-    ::fast_io::u8obuf_file u8obf(at(subdir), u8"hellou8.txt");
-    println(u8obf, u8"Hello World for subdir\n");
-}
-      
-
- -
-

Native File Loader

-

- native_file_loader uses the operating system’s memory mapping API (if available) - to load an entire file into memory. The file is exposed as a contiguous container, allowing - iteration and direct access. -

-

-#include <fast_io.h>
-
-using namespace fast_io::io;
-
-int main(int argc, char **argv)
-{
-    if (argc != 2)
-    {
-        if (argc == 0)
-        {
-            return 1;
-        }
-        perr("Usage: ", fast_io::mnp::os_c_str(*argv), " <file>\n");
-        return 1;
-    }
-    fast_io::native_file_loader loader(::fast_io::mnp::os_c_str(argv[1]));
-    // This will load the entire file into memory through memory mapping.
-    /*
-    This is a contiguous container of the file.
-    You can do things like:
-    std::size_t sum{};
-    for(auto e : loader)
-        sum += e;
-    */
-    print(loader);
-}
-      
-
- - -
- - diff --git a/docs/docs/05.filetypelayers/index.html b/docs/docs/05.filetypelayers/index.html deleted file mode 100644 index 5a9e80f0..00000000 --- a/docs/docs/05.filetypelayers/index.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - File Type Layers - fast_io Documentation - - - - -
-

File Type Layers

- -
-

Overview

-

- fast_io organizes its file types into six layers. Each layer corresponds to a - different level of abstraction, from direct operating system calls up to C and C++ runtime - facilities. On top of these file types, fast_io provides operations - that unify input and output for all of them through Concepts. -

-
- -
-

Hierarchy of File Types

-

From bottom to top:

-
    -
  1. wine
  2. -
  3. nt
  4. -
  5. win32
  6. -
  7. posix
  8. -
  9. c
  10. -
  11. filebuf
  12. -
-
- -
-

Explainations for the Hierarchy of File Types

-

From bottom to top:

-
    -
  1. - wine — - ::fast_io::wine_file is the lowest layer used when running Windows binaries on POSIX systems (e.g. Linux, FreeBSD) via Wine. It directly interacts with Wine’s emulated NT kernel APIs. -
  2. -
  3. - nt — - ::fast_io::nt_file accesses the Windows NT kernel directly via NtWriteFile and related syscalls. This is the most native and lowest-level file interface on modern Windows systems (NT, 2000, XP, 7, 10, etc). -
  4. -
  5. - win32 — - ::fast_io::win32_file wraps the Win32 API’s WriteFile function via kernel32.dll. It is higher-level than NT and used for compatibility with user-mode Windows applications. -
  6. -
  7. - posix — - ::fast_io::posix_file wraps POSIX-style file descriptors and maps to write(2) on Unix-like systems. On Windows, it is emulated via MSVCRT or UCRT. -
  8. -
  9. - c — - ::fast_io::c_file exposes the C standard library’s FILE* interface (e.g. fwrite(3)). It provides buffering and is widely used in legacy C code. -
  10. -
  11. - filebuf — - ::fast_io::filebuf_file exposes the C++ standard library’s std::filebuf* interface, used by std::fstream. It is the highest-level abstraction and integrates with C++ I/O streams. -
  12. -
-
- -
-

Unbuffered Layers

-

- The first four layers are unbuffered. They map directly to OS APIs and do not - add buffering: -

- -

- Each of these also has character type variants, for example: -

- -

- These variants allow working with UTF‑8, UTF‑32, or wide character filenames depending - on platform conventions. -

-
- -
-

Buffered Layers

-

- The top two layers expose existing buffered facilities provided by the C and C++ runtime - libraries: -

- -

- Note: filebuf_file only has ::fast_io::filebuf_file and - ::fast_io::wfilebuf_file. Why? Because the C++ standard library never - implemented basic functionality for other character types such as - ::fast_io::u8filebuf_file. Only narrow and wide character streams are - supported. -

-
- -
-

Moving Between Layers

-

- You can construct higher‑level types from lower ones (through std::move), or go - back down (through static_cast). -

-

-// Lower to higher
-::fast_io::nt_file nfl("nt.txt", ::fast_io::open_mode::out);
-print(nfl, "Hello World from nt_file\n");
-
-::fast_io::filebuf_file fbf(std::move(nfl), ::fast_io::open_mode::out);
-print(fbf, "Hello World from filebuf_file\n");
-
-// Higher to lower
-::fast_io::filebuf_file fbf2("fb.txt", ::fast_io::open_mode::out);
-::fast_io::nt_io_observer niob{static_cast<::fast_io::nt_io_observer>(fbf2)};
-print(niob, "Hello World from nt_io_observer\n");
-      
-
- -
-

Observers

-

- Types like xxx_io_observer are simple aggregates that store a handle. They are - trivially copyable, have no destructors, and let you safely pass handles around without - ownership semantics. -

-

-void foo(FILE* fp) {
-    ::fast_io::c_io_observer ciob{fp};
-    print(ciob, "Hello World from c_io_observer\n");
-
-    ::fast_io::nt_io_observer niob{static_cast<::fast_io::nt_io_observer>(ciob)};
-    print(niob, "Hello World from nt_io_observer\n");
-
-    // Inspect native handle
-    print(::fast_io::mnp::handlevw(niob.native_handle()));
-}
-      
-
- -
-

Native File and iobuf_file

-

- ::fast_io::native_file is an alias to the most appropriate unbuffered file type for - the platform: -

- -

- basic_iobuf_file is defined as: -

-

-template<std::integral char_type>
-using basic_iobuf_file = basic_iobuf<basic_native_file<char_type>>;
-      
-

- This means iobuf_file is a buffered stream built directly on top of the native file - type for your system. -

-
- -
-

Interop with fstream

-

- You can construct a C++ fstream from system calls using fast_io. Here’s - a simplified example without the middle c_file layer: -

-

-#include <fast_io_legacy.h>
-#include <fstream>
-
-int main() {
-    ::fast_io::posix_file pf("posix_file.txt", ::fast_io::open_mode::out);
-    ::fast_io::filebuf_file fbf(std::move(pf), ::fast_io::open_mode::out);
-
-    std::ofstream fout;
-    *fout.rdbuf() = std::move(*fbf.fb);
-
-    fout << "Hello World from std::ofstream\n";
-
-    ::fast_io::filebuf_io_observer fiob{fout.rdbuf()};
-    print(fiob, "Hello World from fast_io::filebuf_io_observer\n");
-}
-      
-

- If you don’t need fstream, using std::ostream directly with - *rdbuf() is even simpler and avoids the overhead of fstream. -

-
- - -
- - diff --git a/docs/docs/api/index.html b/docs/docs/api/index.html deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/docs/intro/index.html b/docs/docs/intro/index.html deleted file mode 100644 index 9fa1cc15..00000000 --- a/docs/docs/intro/index.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - Introduction - fast_io Documentation - - - - -
-

Introduction to fast_io

- -
-

Early Discoveries

-

- My interest in building a new I/O library began in high school. While exploring - performance benchmarks online and running my own tests, I discovered that both - ifstream and stdio were painfully slow. In many cases, - they were at least 5× slower, and on some platforms even - 10× to 100× slower, compared to simply reading an entire file - into memory and parsing it manually. -

-

- This inefficiency convinced me that the standard I/O facilities in C++ were - fundamentally flawed and needed a complete rethinking. -

-
- -
-

Generic Programming vs. OOP

-

- I was a strong admirer of the generic programming paradigm used - in the C++ standard library’s containers and algorithms. They demonstrated how - templates could provide both flexibility and performance. Yet, I/O in C++ felt - inconsistent: iostream leaned heavily on object-oriented programming, - with virtual inheritance at its core. This design choice introduced complexity - and inefficiency, and it stood in stark contrast to the elegance of generic - programming elsewhere in the language. -

-
- -
-

The Problem with Format Strings

-

- Another major frustration was the reliance on format strings. - I always considered them redundant and unsafe. My years of programming in - Lua, particularly while developing World of Warcraft addons, - gave me a different perspective. Lua’s defaults often felt more correct than - C++, though Lua itself had its own flaws. -

-

- I came to believe that format strings should be eliminated entirely. No matter - how you constrain them — even at compile time — they remain vulnerable. Macros, - code generators, or even AI-generated code can reintroduce format string - vulnerabilities. The complexity never truly disappears. In my view, format - strings are a trillion-dollar historical mistake, comparable - to the infamous gets() function. Since gets() was - itself an I/O function in stdio, this only reinforced my belief - that the entire stdio system is extremely dangerous. -

-
- -
-

The Birth of fast_io

-

- In 2013, when Bjarne Stroustrup introduced concepts prototypes - at CppCon, I had a breakthrough idea: why not use concepts to rewrite the entire - I/O subsystem? That was the moment fast_io was born — at least - in theory. I built an early prototype using GCC’s experimental concepts - implementation, just to prove the idea was viable. -

-

- Unfortunately, concepts were still immature at the time, existing only as a - Technical Specification (TS). Without proper standard library support, - fast_io couldn’t move beyond a prototype. The real - implementation only began in earnest around 2020, once concepts became part of - mainstream C++. -

-
- -
-

Refinement and Philosophy

-

- Even after 2020, fast_io went through multiple waves of - refactoring. My goal was not just to make it functional, but to make it - good — elegant, portable, and robust. Because it is concepts-based, - the library is designed to work across all platforms, and even in environments - without operating systems. -

-

- Herb Sutter’s talk on Herbceptions further influenced my vision. - Since I/O is one of the largest consumers of exceptions in C++, I realized that - fast_io would eventually need to integrate Herbceptions to - truly complete its design. Until that happens, the library will continue to - evolve, with APIs gradually stabilizing as the design matures. -

-
- -
-

Backwards Compatibility

-

- A key design principle of fast_io is backwards compatibility. - The library is built to interoperate with multiple existing systems: - wine (host file descriptors), NT handles, - Win32 handles, POSIX file descriptors, - stdio, and even filebuf from - iostream/fstream. Considerable effort has gone into making these - systems compatible with one another under a unified interface. -

-
- -
-

Freestanding Environments

-

- Because fast_io is intended to work everywhere, including - freestanding environments, I came to realize that many features advocated by - the C++ community — exception handling (EH), RTTI, vector, - array, and others — simply do not function reliably outside of - hosted environments. This reinforced the need for a library that is both - freestanding-friendly and conceptually modern. -

-
- -
-

Looking Ahead

-

- fast_io is more than just an I/O library. It is a proof of - concept — a demonstration to WG21 and the broader C++ community that I/O can - be reimagined using modern language features. It is a statement against - inefficiency, redundancy, and outdated design patterns. And it is a commitment - to building tools that are both fast and conceptually clean. -

-
-
-

Video Introduction

-

- Here’s a talk that further illustrates the ideas behind fast_io: -

-
- -
-
- - -
- - - diff --git a/docs/icons/logo.png b/docs/icons/logo.png deleted file mode 100644 index 8f4faefb..00000000 Binary files a/docs/icons/logo.png and /dev/null differ diff --git a/docs/icons/logo.webp b/docs/icons/logo.webp deleted file mode 100644 index bf036079..00000000 Binary files a/docs/icons/logo.webp and /dev/null differ diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 5ca2fa1e..00000000 --- a/docs/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - fast_io - fast_io documentations (Under Construction) - - - - -

fast_io

- - - - - - - - diff --git a/docs/manifest.json b/docs/manifest.json deleted file mode 100644 index bcaf4494..00000000 --- a/docs/manifest.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "fast_io", - "short_name": "fast_io", - "start_url": "/", - "id": "/", - "display": "standalone", - "background_color": "#000000", - "theme_color": "#000000", - "icons": [ - { - "src": "icons/logo.webp", - "sizes": "512x512", - "type": "image/webp" - }, - { - "src": "icons/logo.png", - "sizes": "512x512", - "type": "image/png" - } - ] -} diff --git a/docs/script.js b/docs/script.js deleted file mode 100644 index fe796548..00000000 --- a/docs/script.js +++ /dev/null @@ -1,2 +0,0 @@ -// Insert the current year at runtime -document.getElementById("current-year").textContent = new Date().getFullYear(); diff --git a/docs/style.css b/docs/style.css deleted file mode 100644 index e278f88e..00000000 --- a/docs/style.css +++ /dev/null @@ -1,81 +0,0 @@ -/* Default (light mode) */ -body { - background-color: #ffffff; - color: #000000; - font-family: sans-serif; - margin: 0; - padding: 1rem; -} - -nav a { - margin-right: 1rem; - text-decoration: none; - color: #0066cc; -} - -footer { - margin-top: 2rem; - font-size: 0.9rem; - color: #555; -} - -/* Dark mode */ -@media (prefers-color-scheme: dark) { - body { - background-color: #000000; - color: #ffffff; - } - - nav a { - color: #66ccff; - } - - footer { - color: #aaa; - } -} - -nav a { - display: block; /* Each link takes a full line */ - margin: 0.5rem 0; /* Add vertical spacing between links */ - text-decoration: none; - color: #66ccff; /* Adjust color for dark mode */ -} - -.page-navigation { - margin-top: 2rem; - display: flex; - justify-content: space-between; /* pushes prev left, next right */ -} - -.prev-button, -.next-button { - display: inline-block; - padding: 0.6rem 1.2rem; - background-color: #0066cc; - color: #fff; - text-decoration: none; - border-radius: 4px; - font-weight: bold; -} - -.prev-button:hover, -.next-button:hover { - background-color: #004c99; -} - -.video-container { - position: relative; - width: 100%; /* take full width of text content area */ - padding-bottom: 56.25%; /* 16:9 aspect ratio (height = 9/16 of width) */ - height: 0; - overflow: hidden; -} - -.video-container iframe { - position: absolute; - top: 0; - left: 0; - width: 100%; /* scale to container width */ - height: 100%; /* scale height accordingly */ -} diff --git a/docs/sw-register.js b/docs/sw-register.js deleted file mode 100644 index f2f6f36b..00000000 --- a/docs/sw-register.js +++ /dev/null @@ -1,5 +0,0 @@ -if ("serviceWorker" in navigator) { - navigator.serviceWorker.register("sw.js") - .then(() => console.log("Service Worker registered")) - .catch(err => console.error("SW registration failed:", err)); -} diff --git a/docs/sw.js b/docs/sw.js deleted file mode 100644 index 3629a24d..00000000 --- a/docs/sw.js +++ /dev/null @@ -1,28 +0,0 @@ -const CACHE_NAME = "fast_io-docs-v3"; -const urlsToCache = [ - "/", - "/style.css", - "/script.js", - "/sw-register.js", - "/manifest.json", - "/icons/logo.webp", - "/docs/intro/", -// "/docs/api/", - "/docs/01.helloworld/", - "/docs/02.aplusb/", - "/docs/03.pointer/", - "/docs/04.fileio/", - "/docs/05.filetypelayers/", -]; - -self.addEventListener("install", event => { - event.waitUntil( - caches.open(CACHE_NAME).then(cache => cache.addAll(urlsToCache)) - ); -}); - -self.addEventListener("fetch", event => { - event.respondWith( - caches.match(event.request).then(response => response || fetch(event.request)) - ); -});