A blazingly fast, header-only, zero-allocation string library for modern C++.
- π Zero Heap Allocations - Everything on the stack
- β‘ Blazingly Fast - 5-20x faster than
std::string - π Functional Piping - Chain operations with
| - π¦ Header-Only - Just drop it in your project
- π― Constexpr Everything - Compile-time string manipulation
- π‘οΈ Type-Safe - Modern C++20 concepts
- π¨ Rich API - 50+ string operations
#include <zuu/fstring.hpp>
using namespace zuu;
using namespace zuu::str;
using namespace zuu::fmt;
int main() {
// Functional piping π
auto result = " HELLO WORLD "_sfs
| trim
| to_lower
| [](auto s) { s += "!!!"; return s; };
// result == "hello world!!!"
// Modern formatting π¨
std::cout << to_fstring(hex(255)) << '\n'; // "0xff"
std::cout << to_fstring(bin(42)) << '\n'; // "0b101010"
std::cout << to_fstring(pad_left(7, 3)) << '\n'; // "007"
// Split & Join π¦
auto parts = split("a,b,c"_fs, ',');
for (const auto& part : parts) {
std::cout << part << '\n';
}
return 0;
}# Clone the repository
git clone https://github.com/zugyonozz/fstring.git
# Copy headers to your project
cp -r fstring/include/zuu /path/to/your/project/include/include(FetchContent)
FetchContent_Declare(
zuu_fstring
GIT_REPOSITORY https://github.com/zugyonozz/fstring.git
GIT_TAG v3.0.0
)
FetchContent_MakeAvailable(zuu_fstring)
target_link_libraries(your_target PRIVATE zuu::fstring)mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
sudo cmake --build . --target installThen in your CMakeLists.txt:
find_package(zuu_fstring REQUIRED)
target_link_libraries(your_target PRIVATE zuu::fstring)- C++20 compiler
- GCC 11+
- Clang 12+
- MSVC 2019+ (19.29+)
- AppleClang 13+
- Quick Reference - API cheat sheet
- Migration Guide - Upgrading from v2.0
- Troubleshooting - Common issues
- Full API Docs - Complete reference
Chain operations naturally:
auto result = " input "_sfs
| trim
| to_upper
| [](auto s) { return s + "!"; };// Case conversion
auto lower = "HELLO"_sfs | to_lower;
auto upper = "hello"_sfs | to_upper;
auto title = "hello world"_sfs | to_title;
// Trimming
auto trimmed = " text "_sfs | trim;
// Split & Join
auto parts = split("a,b,c"_sfs, ',');
auto joined = join(parts, ", "_sfs);
// Search
bool has = contains("hello"_sfs, 'e');
bool starts = starts_with("hello"_sfs, "he");
size_t pos = find("hello"_sfs, 'l');// Proxy object pattern
auto hex_str = to_fstring(hex(255)); // "0xff"
auto bin_str = to_fstring(bin(42)); // "0b101010"
auto padded = to_fstring(pad_left(7, 5)); // "00007"
// Parsing
int val = parse_int<int>("42"_sfs);
float f = parse_float<float>("3.14"_sfs);using namespace types;
name_str username = "alice"; // 64 capacity
path_str file = "/usr/local/bin"; // 260 capacity
uuid_str id = "550e8400-e29b..."; // 36 capacity
ip_str address = "192.168.1.1"; // 45 capacity
email_str contact = "user@example.com"; // 254 capacityconstexpr auto compile_time() {
fstring<32> s = "test";
return s | to_upper; // All at compile-time!
}
static_assert(compile_time() == "TEST");Benchmark results (GCC 13, -O3):
| Operation | fstring | std::string | Speedup |
|---|---|---|---|
| Construction | 2 ns | 45 ns | 22.5x |
| Concatenation | 8 ns | 67 ns | 8.4x |
| to_upper | 12 ns | 89 ns | 7.4x |
| trim | 15 ns | 102 ns | 6.8x |
| split | 45 ns | 234 ns | 5.2x |
| Heap Allocations | 0 | 3-5 | β |
// URL parsing
auto url = "https://example.com/path?key=value"_fs;
auto parts = split_by(url, "://"_sfs);
auto domain = parts[1] | split('/') | [](auto p) { return p[0]; };// INI-like format
auto config = "key = value # comment"_fs;
auto cleaned = config | split('#') | [](auto p) { return p[0]; } | trim;
auto kv = split(cleaned, '=');// Parse log lines
for (const auto& line : log_data | split_lines) {
auto fields = line | trim | split_whitespace;
process_log(fields[0], fields[1], fields[2]);
}// CSV generation
fstring<256> csv;
csv = join(fields, ","_sfs);| Feature | fstring | std::string | std::string_view |
|---|---|---|---|
| Heap Allocations | β (0) | β (Multiple) | β (0) |
| Mutable | β | β | β |
| Constexpr | β | β | |
| Piping | β | β | β |
| Fixed Capacity | β | β | N/A |
| Ownership | β | β | β (View only) |
| Rich API | β (50+) | β |
# Clone repository
git clone https://github.com/zugyonozz/fstring.git
cd fstring
# Build examples
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
# Run tests
./test_comprehensive
# Run examples
./example_modern_usageContributions welcome! Please see CONTRIBUTING.md.
- Unicode support (UTF-8 validation)
- Advanced pattern matching
- SIMD optimizations
- More comprehensive tests
MIT License - see LICENSE file.
- Inspired by Rust's
Stringand Python's string methods - Built with modern C++20 features
- Community feedback and contributions
- Author: zugyonozz
- Email: rafizuhayr001@gmail.com
- GitHub: https://github.com/zugyonozz/fstring
- Issues: https://github.com/zugyonozz/core/issues
- Unicode normalization
- Regex-like pattern matching
- SIMD-accelerated operations
- Custom allocator support
- Network serialization helpers
- JSON integration
- Breaking: API refinements
- C++23 features
- Enhanced constexpr support
β If you find this useful, please star the repository!
Made with β€οΈ by zugyonozz