{"id":13521352,"url":"https://github.com/TheNumbat/rpp","last_synced_at":"2025-03-31T20:31:17.578Z","repository":{"id":196395861,"uuid":"690168526","full_name":"TheNumbat/rpp","owner":"TheNumbat","description":"Minimal Rust-inspired C++20 STL replacement","archived":false,"fork":false,"pushed_at":"2024-06-13T01:55:58.000Z","size":508,"stargazers_count":123,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-02T06:12:13.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheNumbat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-11T17:00:55.000Z","updated_at":"2024-07-22T01:07:35.000Z","dependencies_parsed_at":"2023-12-16T04:54:47.502Z","dependency_job_id":"e9ea16aa-1d8f-4cdd-88fb-01f736cb93f3","html_url":"https://github.com/TheNumbat/rpp","commit_stats":null,"previous_names":["thenumbat/rpp"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNumbat%2Frpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNumbat%2Frpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNumbat%2Frpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNumbat%2Frpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheNumbat","download_url":"https://codeload.github.com/TheNumbat/rpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222679160,"owners_count":17021812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:00:33.104Z","updated_at":"2025-03-31T20:31:17.572Z","avatar_url":"https://github.com/TheNumbat.png","language":"C++","readme":"# rpp\n\n[![Windows](https://github.com/TheNumbat/rpp/actions/workflows/windows.yml/badge.svg)](https://github.com/TheNumbat/rpp/actions/workflows/windows.yml)\n[![Linux](https://github.com/TheNumbat/rpp/actions/workflows/linux.yml/badge.svg)](https://github.com/TheNumbat/rpp/actions/workflows/linux.yml)\n[![Linux (aarch64)](https://github.com/TheNumbat/rpp/actions/workflows/linux-arm64.yml/badge.svg)](https://github.com/TheNumbat/rpp/actions/workflows/linux-arm64.yml)\n[![macOS](https://github.com/TheNumbat/rpp/actions/workflows/macos.yml/badge.svg)](https://github.com/TheNumbat/rpp/actions/workflows/macos.yml)\n[![macOS (aarch64)](https://github.com/TheNumbat/rpp/actions/workflows/macos-arm64.yml/badge.svg)](https://github.com/TheNumbat/rpp/actions/workflows/macos-arm64.yml)\n\nMinimal Rust-inspired C++20 STL replacement.\nRefer to the [blog post](https://thenumb.at/rpp/) for details.\n\nGoals:\n- Fast Compilation\n- Debuggability\n- High Performance\n- Explicit Code\n- Easy Metaprogramming\n\n## Integration\n\nTo use rpp in your project, run the following command (or manually download the source):\n\n```bash\ngit submodule add https://github.com/TheNumbat/rpp\n```\n\nThen add the following lines to your CMakeLists.txt:\n\n```cmake\nadd_subdirectory(rpp)\ntarget_link_libraries($your_target PRIVATE rpp)\ntarget_include_directories($your_target PRIVATE ${RPP_INCLUDE_DIRS})\n```\n\nTo use rpp with another build system, add `rpp` to your include path, add `rpp/rpp/impl/unify.cpp` to the build, and add either `rpp/rpp/pos/unify.cpp` or `rpp/rpp/w32/unify.cpp` based on your platform.\n\n## Platform Support\n\nThe following configurations are supported:\n\n| OS      | Compiler    | Arch         |\n|---------|-------------|--------------|\n| Windows | MSVC 19.39+ | x64          |\n| Linux   | Clang 17+   | x64, aarch64 |\n| macOS   | Clang 17+   | x64, aarch64 |\n\nExcept for MSVC on Windows, the [gcc vector extensions](https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html) (also [implemented by clang](https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors)) are used to emit SIMD operations.\nOn Linux, other architectures should therefore work, but they have not been tested.\n\nOther configurations (GCC, etc.) may be added in the future.\n\n## Examples\n\n### Logging\n\n```cpp\n#include \u003crpp/base.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    assert(true);\n    info(\"Information\");\n    warn(\"Warning\");\n    die(\"Fatal error (exits)\");\n}\n```\n\n### Data Structures\n\n```cpp\n#include \u003crpp/base.h\u003e\n#include \u003crpp/rc.h\u003e\n#include \u003crpp/stack.h\u003e\n#include \u003crpp/heap.h\u003e\n#include \u003crpp/tuple.h\u003e\n#include \u003crpp/variant.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    Ref\u003ci32\u003e ref;\n    Box\u003ci32\u003e box;\n    Rc\u003ci32\u003e rc;\n    Arc\u003ci32\u003e arc;\n    Opt\u003ci32\u003e optional;\n    Storage\u003ci32\u003e storage;\n    String\u003c\u003e string;\n    String_View string_view;\n    Array\u003ci32, 1\u003e array;\n    Vec\u003ci32\u003e vec;\n    Slice\u003ci32\u003e slice;\n    Stack\u003ci32\u003e stack;\n    Queue\u003ci32\u003e queue;\n    Heap\u003ci32\u003e heap;\n    Map\u003ci32, i32\u003e map;\n    Pair\u003ci32, i32\u003e pair;\n    Tuple\u003ci32, i32, i32\u003e tuple;\n    Variant\u003ci32, f32\u003e variant{0};\n    Function\u003ci32()\u003e function{[]() { return 0; }};\n}\n```\n\n### Allocators\n\n```cpp\n#include \u003crpp/base.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    using A = Mallocator\u003c\"A\"\u003e;\n    using B = Mallocator\u003c\"B\"\u003e;\n    {\n        Vec\u003ci32, A\u003e a;\n        Vec\u003ci32, B\u003e b;\n        info(\"A allocated: %\", a);\n        info(\"B allocated: %\", b);\n\n        Box\u003ci32, Mpool\u003e pool;\n        info(\"Pool allocated: %\", pool);\n\n        Region(R) {\n            Vec\u003ci32, Mregion\u003cR\u003e\u003e region{1, 2, 3};\n            info(\"Region allocated: %\", region);\n        }\n    }\n    Profile::finalize(); // Print statistics and check for leaks\n}\n```\n\n### Trace\n\n```cpp\n#include \u003crpp/base.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    Profile::begin_frame();\n    Trace(\"Section\") {\n        // ...\n    }\n    Profile::end_frame();\n\n    Profile::iterate_timings([](Thread::Id id, const Profile::Timing_Node\u0026 n) {\n        // ...\n    });\n}\n```\n\n### Reflection\n\n```cpp\n#include \u003crpp/base.h\u003e\n\nusing namespace rpp;\n\nstruct Foo {\n    i32 x;\n    Vec\u003ci32\u003e y;\n};\nRPP_RECORD(Foo, RPP_FIELD(x), RPP_FIELD(y));\n\ntemplate\u003cReflectable T\u003e\nstruct Bar {\n    T t;\n};\ntemplate\u003cReflectable T\u003e\nRPP_TEMPLATE_RECORD(Bar, T, RPP_FIELD(t));\n\ni32 main() {\n    Bar\u003cFoo\u003e bar{Foo{42, Vec\u003ci32\u003e{1, 2, 3}}};\n    info(\"bar: %\", bar);\n}\n```\n\n### Thread\n\n```cpp\n#include \u003crpp/base.h\u003e\n#include \u003crpp/thread.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    Thread::set_priority(Thread::Priority::high);\n\n    auto future = Thread::spawn([]() {\n        info(\"Hello from thread %!\", Thread::this_id());\n        return 0;\n    });\n\n    info(\"Thread returned: %\", future-\u003eblock());\n}\n```\n\n### Async\n\n```cpp\n#include \u003crpp/base.h\u003e\n#include \u003crpp/pool.h\u003e\n#include \u003crpp/asyncio.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    Async::Pool\u003c\u003e pool;\n\n    auto coro = [](Async::Pool\u003c\u003e\u0026 pool) -\u003e Async::Task\u003ci32\u003e {\n        co_await pool.suspend();\n        info(\"Hello from thread %!\", Thread::this_id());\n        co_await Async::wait(pool, 100);\n        co_return 0;\n    };\n\n    auto task = coro(pool);\n    info(\"Task returned: %\", task.block());\n}\n```\n\n### Math\n\n```cpp\n#include \u003crpp/base.h\u003e\n#include \u003crpp/vmath.h\u003e\n#include \u003crpp/simd.h\u003e\n\nusing namespace rpp;\n\ni32 main() {\n    Vec3 v{0.0f, 1.0f, 0.0f};\n    Mat4 m = Mat4::translate(v);\n    info(\"Translated: %\", m * v);\n\n    auto simd = SIMD::F32x4::set1(1.0f);\n    info(\"Dot product: %\", SIMD::F32x4::dp(simd, simd));\n}\n```\n\n## Build and Run Tests\n\nTo build rpp and run the tests, run the following commands:\n\n### Windows\n\nAssure MSVC 19.39 and cmake 3.17 (or newer) are installed and in your PATH.\n\n```bash\nmkdir build\ncd build\ncmake .. -DRPP_TEST=ON\ncmake --build .\nctest -C Debug\n```\n\nFor faster parallel builds, you can instead generate [ninja](https://ninja-build.org/) build files with `cmake -G Ninja ..`.\n\n### Linux\n\nAssure clang-17 and cmake 3.17 (or newer) are installed.\n\n```bash\nmkdir build\ncd build\nCXX=clang++-17 cmake .. -DRPP_TEST=ON\nmake -j\nctest -C Debug\n```\n\nFor faster parallel builds, you can instead generate [ninja](https://ninja-build.org/) build files with `cmake -G Ninja ..`.\n\n## To-Dos\n\n- Modules\n- Async\n    - [ ] scheduler priorities\n    - [ ] scheduler affinity\n    - [ ] scheduler work stealing\n    - [ ] io_uring for Linux file IO\n    - [ ] sockets\n    - [ ] use relaxed atomics on aarch64\n- Types\n    - [ ] Result\u003cT,E\u003e\n    - [ ] Map: don't store hashes of integer keys\n    - [ ] Opt: specializations for null representations\n- Allocators\n    - [ ] Allow reallocating the topmost stack allocation\n    - [ ] Per-thread pools\n- Misc\n    - [ ] Range_Allocator: add second level of linear buckets\n    - [ ] Range_Allocator: reduce overhead\n","funding_links":[],"categories":["Frameworks","未分类"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheNumbat%2Frpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTheNumbat%2Frpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTheNumbat%2Frpp/lists"}