↧
Answer by HolyBlackCat for Why does SDL_RWFromConstMem() size need type int...
Even if a value can't be negative, it doesn't necessarily mean you should use an unsigned type for it. The main benefit they have is ability to store larger positive values, but the downside is that...
View ArticleComment by HolyBlackCat on Linking a multilibrary project statically to...
"libProduct uses the libstdc++ symbols from libHelper" - Huh? How do you know that? What I would do is link libstdc++ dynamically, ship your copy of it along with your library, then tell them to use...
View ArticleComment by HolyBlackCat on How do you deduce the size of a std::array?
to_array is good when you want to force a specific element type, but causes the elements to be moved from a temporary array. So if you don't need to manually set the element type, prefer std::array{...}.
View ArticleComment by HolyBlackCat on Own type as key in unordered_map
Having an implicit conversion to uint32_t removes some of the advantages you gain by having a custom type in the first place, IMO.
View ArticleComment by HolyBlackCat on What problem in the C++ code for function template...
Doesn't the box explain the problem? max (max(a,b), c) in this case returns const char* by value, which a temporary. You then return a reference to it, and the temporary dies right after returning from...
View ArticleComment by HolyBlackCat on Are function calls guaranteed to be strict in C?
If you're asking if all parameters are evaluated before the call, then yes. always_inline has no effect on this and on anything else other than performance.
View ArticleComment by HolyBlackCat on I'm a little confused in namespaces in C++
using namespace is weird. It doesn't bring the target namespace to the current scope, rather it brings it to the common enclosing namespace of the current and target namespace, which in practice means...
View ArticleComment by HolyBlackCat on VSCode Devcontainer terminal unable to git fetch
Try ssh -T git@github.com to test the SSH connection.
View ArticleAnswer by HolyBlackCat for Can you declare a lambda variable without auto...
No, the type of each lambda is unique and unnamed, so there's nothing you could replace auto with without at least some change in semantics.std::function (and other std::..._function classes) have...
View ArticleComment by HolyBlackCat on C++ Registry Pattern
"it invokes undefined behavior ... no guarantee these run" Your quote doesn't say "undefined behavior", it says "implementation-defined [whether it works or not]", it's a different thing. We've been...
View ArticleComment by HolyBlackCat on std::println/print not working in gcc 14.1
Works for me on Linux. Likely a broken compiler.
View ArticleComment by HolyBlackCat on indeterminate number returned in for loop C++
You have undefined behavior somewhere else. Enable the address sanitizer and see if it catches it. Container bounds checks help too. How to enable those two depends on your compiler.
View ArticleComment by HolyBlackCat on Why are there code blocks and possibly unneeded...
Are the braces empty or not? You need braces if you declare variables inside (unless it's the last label in switch, but it's easier to add them everywhere for consistency).
View ArticleComment by HolyBlackCat on clang frontend command failed with exit code 139
Is this is some ancient version of Emscripten? The latest runs Clang 19.
View ArticleComment by HolyBlackCat on Conflicting intellisense popup message
You should generate compiler_commands.json for your project, how to do that depends on your build tool. Then Intellisense should be able grab to compiler flags from it automatically, which should...
View ArticleComment by HolyBlackCat on constexpr vs constexpr inline vs define -...
constexpr functions are implicitly inline, so (2) is just a more verbose version of (1). Are you worried about just release build performance, or debug performance too? Did you compare the resulting...
View ArticleComment by HolyBlackCat on Why can't I use std::vector::emplace_back without...
You should add the error message to the question.
View ArticleComment by HolyBlackCat on struct component is not found and the library...
Please show the exact error message you get, and try to reduce your code to a minimal reproducible example.
View ArticleComment by HolyBlackCat on Is seperating recursive part of function from the...
Or in C++23: auto calc = [](this auto &calc, int x) -> int {/*...*/};return calc(x);.
View Article
More Pages to Explore .....