↧
Comment by HolyBlackCat on What is the difference between std::fill_n and...
Even if there's no meaningful difference other than stricter concept checks, the point is that std::ranges should have alternatives for all algorithms, so that you don't have to touch the old ones ever...
View ArticleComment by HolyBlackCat on is this Undefined Behavior? (casting away const...
@wohlstad Not all lvalues are named.
View ArticleAnswer by HolyBlackCat for Is it enough to have forward declaration of...
In general a forward declaration is enough, but it's not an option for standard classes, because there is no legal way to forward-declare them.They and namespace std may or may not have...
View ArticleAnswer by HolyBlackCat for is this Undefined Behavior? (casting away const...
Looks legal to me.[conv.rval] says that after temporary materialization, the resulting xvalue has the same type as the original prvalue.A prvalue of type T can be converted to an xvalue of type T.42 a...
View ArticleComment by HolyBlackCat on Move semantic: Why does the return statement call...
GCC calls the move constructor in the second snippet if you compile with -std=c++20 or newer.
View ArticleComment by HolyBlackCat on How to initialize member std::variant variable...
"and myVar contains garbage" How do you know that?
View ArticleComment by HolyBlackCat on why std::is_same::value is false?
And an "id-expression" is essentially a variable name. Everything else falls through to the second case.
View ArticleComment by HolyBlackCat on C++ map: How do I get the key that was used to add...
@PeteBecker Yep, or compare using std::weak_order() or std::strong_order() to handle nans.
View ArticleAnswer by HolyBlackCat for compilation of member functions using nested class...
Inlining is only about performance, it doesn't affect program correctness.The simple answer is that function bodies are processed at the end of the enclosing class (if the classes are nested, even...
View ArticleComment by HolyBlackCat on Multiple calls to the delete when destructors...
@user17732522 Just tried it locally, and binary MSVC produced crashes, even on OP's code. Maybe they didn't test correctly.
View ArticleComment by HolyBlackCat on Drag and drop feature on SDL2
Wait until the next frame to get the new coords? Or use SDL_GetGlobalMouseState perhaps.
View ArticleComment by HolyBlackCat on How to configure clangd in VSCode to also show the...
Clangd has very few configuration options, so it's unlikely.
View ArticleComment by HolyBlackCat on Unexpected result with `std::views::transform`,...
Huh? Forming a pointer to a temporary would cause a compilation error, not UB. And OP is not doing that, they apply a member pointer to a temporary, which by itself is legal.
View ArticleComment by HolyBlackCat on Unexpected result with `std::views::transform`,...
std::invokeing &S::x returns by reference, while your lambda returns by value. I'm not sure why the former is illegal, but this seems to be the difference.
View ArticleComment by HolyBlackCat on C++ concept that allows empty curly braces
Looks ok to me if you fix formatting.
View ArticleAnswer by HolyBlackCat for Reinterpret cast of void * didn't do what I...
reinterpret_cast<T &>(x) is equivalent to *reinterpret_cast<T *>(&x) (except the former doesn't respect overloaded &, which makes it useful for implementing std::addressof).So...
View ArticleComment by HolyBlackCat on Why does this exception class produce a garbage...
When do you think the buffer pointed by full_msg.c_str() is destroyed?
View ArticleComment by HolyBlackCat on Vscode IntelliSense not working for C/C++ whatever...
Can you show your settings.json? Maybe you customized the default language for .cpp files. You can also try disabling all extensions except for the C/C++ one.
View ArticleComment by HolyBlackCat on Vscode IntelliSense not working for C/C++ whatever...
VSC has some hidden extensions installed by default, they are responsible e.g. for this basic C/C++ syntax highlighting. You can see them in the extension marketplace gui if you search for @builtin.
View ArticleComment by HolyBlackCat on Building with new version of compiler and old libc...
I'm not sure if you can make GCC use a different version of libstdc++, but Clang lets you use any libstdc++ installation.
View Article
More Pages to Explore .....