Comment by HolyBlackCat on Why don't STL containers have methods for general...
The modern way of doing this is std::ranges::find(nameOfLongNamedStdVector, value);. The vector name is not repeated.
View ArticleAnswer by HolyBlackCat for How to validate strings to compile time?
The way libfmt (and std::format) do it is by passing a custom class instead of std::string_view, with a consteval constructor accepting a string. Said constructor runs at compile-time and can e.g....
View ArticleComment by HolyBlackCat on C++ How to extract and use "variadic" template...
I don't understand what this pseudocode is supposed to do. std::tuple<T...> would store all of the args... together, but I don't understand how you want to split them between _data and _expected.
View ArticleComment by HolyBlackCat on How to use the Windows API in MinGW?
-mwindows is irrelevant, it just removes the console window.
View ArticleComment by HolyBlackCat on Using `std::apply` to iterate over `std::tuple`
printAll2 has no type (only printAll2<T> does), so you can't pass it around without either specifying a template argument or casting a function pointer (that deduces that the template argument)....
View ArticleComment by HolyBlackCat on C programming language related issue
Depends on context. void as a function return type means it returns nothing. (void) as a function parameter list means it takes no parameters. In general you can't replace it with an empty line.
View ArticleComment by HolyBlackCat on Simple image recognition
Your "python is slow" is kinda misleading. The underlying math of the popular python libs is most probably implemented in C/C++ anyway, so it's slowness shouldn't be a problem.
View ArticleComment by HolyBlackCat on Can `::` and `*` forming a member pointer type...
@MarekR I'm making a macro that does something like this: FOO(A::B::, c) -> static_cast<R (A::B::*)(...)>(&A::B::c), which is ultimately needed for generating pybind11 bindings.
View ArticleComment by HolyBlackCat on White bars when resizing the window
Do you draw anything at all to the window? Also a minimal reproducible example would be nice.
View ArticleComment by HolyBlackCat on C++: An std::array of div_t type elements: how to...
Have you considered that you debugger could be misbehaving? Or you're not using it correctly (e.g. trying to view the array before it's initialized, try jumping to the next line first).
View ArticleAnswer by HolyBlackCat for C++ Sorting algorithm that sorts every N elements...
Obligatory solution using C++20 ranges:#include <algorithm>#include <iostream>#include <ranges>int main(){ int arr[] = {7,8,6,4,5,1,4,3,5}; int n = 3; for (auto &&segment :...
View ArticleComment by HolyBlackCat on SDL2: How to draw without clearing
Firstly, SDL_WINDOW_METAL is for manually using Metal, I think? Since you're not, I'd remove it. Second, even without that, I don't think not clearing the renderer every frame is portable. You should...
View ArticleComment by HolyBlackCat on clangd in nvim on windows can't resolve standard...
If you want to post an answer, please make sure it's self-contained (explains how exactly to fix it, without having to follow multiple links).
View ArticleComment by HolyBlackCat on Not sure what code that looks like this means?
Removing the cast shouldn't cause a compilation error, but perhaps it causes a warning on some compilers/settings.
View ArticleComment by HolyBlackCat on c++ vs powertech c++ debugger?
"Powertech" seem to be some weirdos that promote their closed-source Clang fork with unspecified changes (other than defaulting to LLD). And their "debugger" extension seems to be a fork of CodeLLDB,...
View ArticleComment by HolyBlackCat on How can I configure the linker in CMake so that it...
-DCMAKE_AR=llvm-ar should make it use llvm-ar, which should be faster than the regular ar.
View ArticleComment by HolyBlackCat on Can folding expressions for variadic templates be...
For starters, please at least use std::array and not std::vector. Second, both of those limit you to the same argument types. Third, you can loop over a pack using an immediately-unvoked lambda:...
View ArticleComment by HolyBlackCat on eval() and exec() in C++
If you want to evaluate math expressions, you'll need to manually implement that, or find a library to do it.
View ArticleComment by HolyBlackCat on How to get data member names with...
Boost.PFR already does this. You can analyze their source, or just use that lib directly.
View ArticleAnswer by HolyBlackCat for Sorting algorithm that sorts every N elements of...
Obligatory solution using C++20 ranges:#include <algorithm>#include <iostream>#include <ranges>int main(){ int arr[] = {7,8,6,4,5,1,4,3,5}; int n = 3; for (auto &&segment :...
View Article