ch
Feedback
C++ - Reddit

C++ - Reddit

前往频道在 Telegram

Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels

显示更多
229
订阅者
无数据24 小时
+17
+230
帖子存档
Any good c++ ui libraries? I was using wxWidgets for a while working on a gui app, but it felt very limited, especially appearance wise, ive heard about Qt but it seems to be a paid thing from my understanding. Do you guys know of any good flexible ui libraries? https://redd.it/1hbvzq4 @r_cpp

Implementing Rust-like traits for C++ 20 (with no runtime overhead) https://github.com/Jaysmito101/rusty.hpp?tab=readme-ov-file#traits-in-c https://redd.it/1hbzqhm @r_cpp

binfuse : New C++ Library for Binary Fuse Filters Binary fuse filters are a recent (2022) development in the group of Approximate Membership Query filters > Approximate membership query filters (hereafter, AMQ filters) > comprise a group of space-efficient probabilistic data structures > that support approximate membership queries. An approximate > membership query answers whether an element is in a set or not with > a false positive rate of ϵ. Binary fuse filters are a further development on XOR filters, which are more space efficient, and faster to build and query than traditional options like Bloom and Cookoo filters. This `binfuse` C++ library builds on the C-libary by the authors of the relevant research paper. As well as adding a convenient C++ interface, binfuse::filter also facilitates (de-)serializing the populated filter to/from disk as well as querying it directly from disk via an mmap, with cross platform support from mio. Both in memory and "off disk" operation is supported. One of the challenges with binary fuse filters, is that they are immutable once populated, so data cannot be added incrementally, and they consume a significant amount of memory during the populate process - 64GB of memory is recommended for populating with 500 million uint64_t keys/hashes. This has, until now, placed an upward bound on the practical application of these filters to very large datasets. binfuse::sharded_filter allows convenient slicing of the dataset into an arbitrary number of shards which are written to disk and indexed by the N most significant bits of the uint64_t keys/hashes. Sharding is transparent to the user during queries is and still very fast with just 3 mmap accesses per query. binfuse::sharded_filter easily controls RAM requirements during the "populate filter" process and enables datasets of 10s of billions of records with common hardware. Query speeds depend on disk hardware and cache conditions, but can be in the sub microsecond range. https://redd.it/1hbxxoq @r_cpp

binfuse C++ Library for Binary Fuse Filters Binary fuse filters are a recent (2022) development in the group of Approximate Membership Query filters > Approximate membership query filters (hereafter, AMQ filters) > comprise a group of space-efficient probabilistic data structures > that support approximate membership queries. An approximate > membership query answers whether an element is in a set or not with > a false positive rate of ϵ. Binary fuse filters are a further development on XOR filters, which are more space efficient, and faster to build and query than traditional options like Bloom and Cookoo filters. This `binfuse` C++ library builds on the C-libary by the authors of the relevant research paper. As well as adding a convenient C++ interface, binfuse::filter also facilitates (de-)serializing the populated filter to/from disk as well as querying it directly from disk via an mmap, with cross platform support from mio. Both in memory and "off disk" operation is supported. One of the challenges with binary fuse filters, is that they are immutable once populated, so data cannot be added incrementally, and they consume a significant amount of memory during the populate process - 64GB of memory is recommended for populating with 500 million uint64_t keys/hashes. This has, until now, placed an upward bound on the practical application of these filters to very large datasets. binfuse::sharded_filter allows convenient slicing of the dataset into an arbitrary number of shards which are written to disk and indexed by the N most significant bits of the uint64_t keys/hashes. Sharding is transparent to the user during queries is and still very fast with just 3 mmap accesses per query. binfuse::sharded_filter easily controls RAM requirements during the "populate filter" process and enables datasets of 10s of billions of records with common hardware. Query speeds depend on disk hardware and cache conditions, but can be in the sub microsecond range. https://redd.it/1hbw9an @r_cpp

Why std::optional has become a view in C++26? What is the rationale behind making std::optional a view in C++26? What about compliance with the semantic requirements for a view that copy/move and destruction should be cheap (with O(1) complexity)?
using Buffer = std::array<std::byte, 1024>;
std::optional<Buffer> buffer = Buffer{};
    
std::optional backup = buffer; // not O(1)
std::optional target = std::move(buffer); // not O(1)
What about passing views as function arguments by value? Is it still a valid and efficient way to handle views in general?
void print(std::ranges::view auto v) // Is it still ok to pass view by value?
{
    for(const auto& elem : v)
    {
        std::cout << elem << '\n';
    }
}
https://redd.it/1hbt2gp @r_cpp

Anthropic’s Model Context Protocol implementation for Oat++ https://github.com/oatpp/oatpp-mcp https://redd.it/1hbqplt @r_cpp

Zen4 IPC on a tight loop This isn't strictly C++ related, but, I did write the program in C++ :) I've got two tight loops:
mov_all_bytes_asm:
    xor rax, rax
.loop:
    mov [rsi + rax], al
    inc rax
    cmp rax, rdi
    jb .loop
    ret

dec_all_bytes_asm:
.loop:
    dec rdi
    jnz .loop
    ret
When I profile these, we get the following results:
--- mov_all_bytes_asm ---
min: 0.205382ms 4.754852GB/s
max: 1.917500ms 0.509289GB/s PF: 256.0000 (4.0000k/fault)
avg: 0.222437ms 4.390287GB/s

 Performance counter stats for './program':

         21,434.24 msec task-clock                       #    1.000 CPUs utilized
               230      context-switches                 #   10.730 /sec
                 6      cpu-migrations                   #    0.280 /sec
               642      page-faults                      #   29.952 /sec
   101,844,214,951      cycles                           #    4.751 GHz
     1,472,029,546      stalled-cycles-frontend          #    1.45% frontend cycles idle
   399,175,011,257      instructions                     #    3.92  insn per cycle
                                                  #    0.00  stalled cycles per insn
    99,426,405,244      branches                         #    4.639 G/sec
        14,603,153      branch-misses                    #    0.01% of all branches

      21.438393210 seconds time elapsed

      21.321460000 seconds user
       0.113015000 seconds sys


--- dec_all_bytes_asm ---
min: 0.208385ms 4.686327GB/s
max: 1.962524ms 0.497605GB/s
avg: 0.218390ms 4.471640GB/s

 Performance counter stats for './program':

         27,816.38 msec task-clock                       #    1.000 CPUs utilized
                94      context-switches                 #    3.379 /sec
                 2      cpu-migrations                   #    0.072 /sec
               130      page-faults                      #    4.674 /sec
   134,097,959,498      cycles                           #    4.821 GHz
     1,262,045,596      stalled-cycles-frontend          #    0.94% frontend cycles idle
   267,161,490,333      instructions                     #    1.99  insn per cycle
                                                  #    0.00  stalled cycles per insn
   132,090,707,894      branches                         #    4.749 G/sec
        19,102,851      branch-misses                    #    0.01% of all branches

      27.817368632 seconds time elapsed

      27.718237000 seconds user
       0.099001000 seconds sys

1. How is a loop with a mov running just as fast as a tight decrement loop? 2. Why is there a slow max-time speed on the decrement? I understand that for mov you have caches, paging, etc. but it just doesn't make sense on the dec. I understand you can buffer your writes and that CPUs are very smart with OoE and such. It's still very strange that the mov loop can runs than the dec loop, with near perfect ILP. It makes zero sense why there is a slow iteration on dec at all. https://redd.it/1hbojw0 @r_cpp

C++ template for Advent of Code with code generation using CMake https://github.com/stfufane/aoc-cpp-template https://redd.it/1hb4nzz @r_cpp

Zero to CMake: A beginner's guide to why CMake works https://buchanan.one/blog/zero-to-cmake/ https://redd.it/1hb01j3 @r_cpp

Love this language but don't know what to do with this language This might sound a bit odd. I first encountered Python a year ago, mainly for machine learning. Since I’m not a CS major, I wanted to supplement my computer science knowledge. Later, during my free time, I taught myself C, and then I came across C++. I really like this language, but I don’t know what to do with it. Nowadays, I mostly use C++ to solve competitive programming problems, but I still don’t understand the purpose of using this language. I’m also wondering if I should just treat it as a hobby—maybe I can just learn whatever I find interesting. By profession, I’m actually a process engineer. https://redd.it/1haz0yj @r_cpp

passing a function an array that is never declared? void getNodeActivationPoints(Glove leftGlove, Glove rightGlove){     (leftGlove).setNodeValues([0.2f,0.25f,0.3f,0.125f,0.15f],[0.93f,0.95f,0.92f,0.85f,0.87f]);     (rightGlove).setNodeValues(0.2f,0.25f,0.3f,0.125f,0.15f,0.93f,0.95f,0.92f,0.85f,0.87f); } //i want to pass this data into the function, the data is just for testing but im guessing it doesnt work like this because the array doesnt know what type its meant to be. is there any way for me to do this or do i have to initialize a variable, set the data there and them pass it in? https://redd.it/1hayf05 @r_cpp

Can compiler inline lambdas? Hi there. I'm a second year CS student, my main language now is C++ and this year I have C++ classes. Yesterday my professor said during the lecture that lambdas can't be inlined and we should use functors instead (at least in cases when lambda is small and it's probable that compiler will inline it) to avoid overhead. As I understand, lambda is a kind of anonymous class with only operator() (and optionally some fields if there are any captures) so I don't see why is it can't be inlined? After the lecture I asked if he meant that only function pointers containing lambdas can't be inlined, but no, he literally meant all the lambdas. Could someone understand why is it or give any link to find out it. I've read some stackoverflow discussions and they say that lambda can be inlined, so it's quite confusing with the lecture information. https://redd.it/1haxo07 @r_cpp

ImGui::NewFrame() throwing an error after second call The error is: "abort() has been called" This is the code: #include <enet/enet.h> #include <glad/glad.h> #include <GLFW/glfw3.h> #include <stb_image/stb_image.h> #include <stb_truetype/stb_truetype.h> #include "gl2d/gl2d.h" #include <iostream> #include <ctime> #include "platformTools.h" #include <raudio.h> #include "platformInput.h" #include "otherPlatformFunctions.h" #include "gameLayer.h" #include <fstream> #include <chrono> #include "errorReporting.h" #include "imgui.h" #include "backends/imgui_impl_glfw.h" #include "backends/imgui_impl_opengl3.h" #include "imguiThemes.h" #ifdef _WIN32 #include <Windows.h> #endif #undef min #undef max int main() { GLFWwindow* window; #pragma region window and opengl permaAssertComment(glfwInit(), "err initializing glfw"); glfwWindowHint(GLFW_SAMPLES, 4); #ifdef __APPLE__ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, 1); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); #endif int w = 500; int h = 500; window = glfwCreateWindow(w, h, "Window", nullptr, nullptr); glfwMakeContextCurrent(window); glfwSwapInterval(1); //permaAssertComment(gladLoadGL(), "err initializing glad"); permaAssertComment(gladLoadGLLoader((GLADloadproc)glfwGetProcAddress), "err initializing glad"); #pragma endregion #pragma region gl2d gl2d::init(); #pragma endregion #pragma region imgui ImGui::CreateContext(); imguiThemes::embraceTheDarkness(); ImGuiIO& io = ImGui::GetIO(); (void)io; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; `//io.ConfigFlags` |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows ImGuiStyle& style = ImGui::GetStyle(); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { style.Colors[ImGuiCol_WindowBg].w = 0.f; style.Colors[ImGuiCol_DockingEmptyBg].w = 0.f; } ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 330"); #pragma endregion while (!glfwWindowShouldClose(window)) { glfwPollEvents(); ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); ImGui::NewFrame(); ImGui::Begin("My Scene"); ImGui::End(); ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); } } https://redd.it/1harvjb @r_cpp

Custom C++ allocators to improve cache locality for lists, maps, … https://github.com/hosseinmoein/Cougar https://redd.it/1hamiz2 @r_cpp