What are MSYS2 environments? How do I pick one?
MSYS2 is said to have different environments.What are they? How do I choose which one to use? What's the difference between MINGW64 and UCRT64?(This Q&A is intended as a canonical duplicate on this...
View ArticleAnswer by HolyBlackCat for What are MSYS2 environments? How do I pick one?
See the official manual. Following environments are available: UCRT64, MINGW64, CLANG64, CLANGARM64, MSYS.UCRT64 is a good default, MINGW64 is popular too, but the alternatives are explained below.The...
View ArticleAnswer by HolyBlackCat for How does one escape backticks in markdown?
Addendum: At least on SO, when the code starts or ends with `, you need to add spaces inside of backticks on both sides.That is, if you want foo`, you must spell it as `` foo` ``, not as ``foo` ``,...
View ArticleComment by HolyBlackCat on How to implement a child interface using...
@463035818_is_not_an_ai The question sounds like FooBar is a part of a library, while FooImpl and BarImpl are clients of that library, so FooFar can't inherit from them. I've amended it a bit.
View ArticleAnswer by HolyBlackCat for MSYS2 Clang++ produces error with filesystem library
After some testing, this is a bug in libstdc++, the GCC's C++ standard library. It's already fixed in the newer versions.This happens any time you do std::filesystem::copy("file", "directory"),...
View ArticleAnswer by HolyBlackCat for Result of expression convertible to a type that...
"Convertible to some T matching concept C" is fundamentally impossible, the compiler isn't going to check all possible conversion targets."Decays to a type matching concept C" is possible, but not with...
View ArticleComment by HolyBlackCat on Any way to have an Implicit Lifetime Type with a...
@JodyHagins My point is that no, compilers are not moving in this regard, they are being very very conservative. People widely rely on this stuff working.
View ArticleComment by HolyBlackCat on Why I can not construct mdspan from 2D C array?
@Rud48 Huh? I'm explaining why this isn't feasible too implement, because of language limitations. "Your code in CE" What code, I didn't post any.
View ArticleOverloaded `&&`/`||` operators in concepts and requires-clauses
I made a macro for the "implies" operator. It works fine in general, but breaks on Clang when used in a concept or a requires-clause.run on gcc.godbolt.orgnamespace detail{ template <typename T>...
View ArticleAnswer by HolyBlackCat for Ternary operator and prolonging the lifetime of a...
const Foo& local = frobnicate ? static_cast<const Gizmo&>(Frobnicate(arg)) : arg;Your solution is correct. Lifetime extension does propagate through static_casts, among other things, so...
View ArticleComment by HolyBlackCat on To obtain correctly aligned memory in the...
@user2138149 operator new returns memory aligned to __STDCPP_DEFAULT_NEW_ALIGNMENT__ (that's 16 on all platforms I just tested) if you don't specify alignment yourself. I think that even if you specify...
View ArticleWhy set the stop flag using `memory_order_seq_cst`, if you check it with...
Herb Sutter, in his "atomic<> weapons" talk, shows several example uses of atomics, and one of them boils down to following: (video link, timestamped)A main thread launches several worker...
View ArticleAnswer by HolyBlackCat for Most concise way to disable copy and move semantics
It's enough to delete the copy operations, then the move operations will get removed automatically.But if you're asking for "concise", according to this chart (by Howard Hinnant):The most concise way...
View ArticleAnswer by HolyBlackCat for Where is it defined that references can be...
The standard uses "reference-compatible with" instead of "more/less cv-qualified" for reference initialization.This is described by [dcl.init.ref]/4 and [dcl.init.ref]/5.The definition of...
View ArticleAnswer by HolyBlackCat for Visual Studio Code C/C++ IntelliSense setting to...
You could switch from the stock C++ intellisense to Clangd. It does show class size and alignment on hover. (And has some other advantages over the stock intellisense too.)
View ArticleAnswer by HolyBlackCat for why does 'using namespace' not take priority when...
As explained on cppreference, using namespace doesn't bring the names into the current scope. It brings them to the most nested common enclosing namespace of the current namespace and the one you're...
View ArticleAnswer by HolyBlackCat for VS Code - can I turn a block selection into a...
The only solution I know is AltShiftIAdd Cursors to Line Ends, that gives you the cursors but without the selection.You can then do ShiftHome to select the lines, or just Home to have the cursors at...
View ArticleComment by HolyBlackCat on How to check that a function result is constexpr...
@Oersted I think the first paragraph of the question is good enough as a layman explanation. If you're looking for something more official, it's somewhere in...
View ArticleHow to check that a function result is constexpr even when the argument is not?
constexpr functions can yield constexpr results even when their arguments are not constexpr, if they are unused. Such is, for example, std::integral_constant::operator T:#include...
View ArticleComment by HolyBlackCat on Differences in constraint validation order between...
@TedLyngmo Something needs to call the function with a bad type for there to be an error. If you remove the concept it and don't call it with a bad type in any other way, yes, it compiles.
View ArticleComment by HolyBlackCat on Checking noexceptness when applying function to a...
@康桓瑋 Added a note to the answer. I think I'll leave this as an exercise to the reader, as it doesn't look too tricky.
View ArticleComment by HolyBlackCat on Makefile: How does a header file change trigger a...
@yapkm01 Your post is a simple example. Similarly, you could have something like 1.o: 1.cpp<tab>g++ 1.cpp -c -o 1.o1.o: 1.h. The last line adds another prerequisite, as if you did 1.o: 1.cpp 1.h...
View ArticleAnswer by HolyBlackCat for Specializing std::tuple_size and std::get for...
The standard library is simply not designed to work with custom tuple-like types. Some other parts of the language do support them (structued bingings, and that's about it)You are not allowed to add...
View ArticleAnswer by HolyBlackCat for Where manually configured keyboard shortcut...
It is at ~/.config/Code/User/keybindings.json. In the same directory as settings.json.You can figure this out by opening the keyboard settings, pressing Open JSON in the top-right corner, and looking...
View ArticleComment by HolyBlackCat on Clang can't value-initialize libstdc++'s...
@cigien Note that {} resolves to the default constructor, not to the initializer_list one.
View ArticleComment by HolyBlackCat on What's the difference between the WIN32 and _WIN32...
@FlorianWinter If not specified otherwise, "Windows" means the OS of course, not the subsystem. :P I've edited the answer to be a bit more clear. And the answer already says "automatically by the...
View ArticleAnswer by HolyBlackCat for C++ friend injection - how does it work, and what...
The example feels a bit overcomplicated. Here's a simpler one:#include <iostream>template <typename Key>struct Reader{ constexpr auto friend get(Reader<Key>);};template <typename...
View ArticleComment by HolyBlackCat on What's the point of deleted virtual functions?
@Oersted Yeah, I think he knows it's different, or it would've been a dupe vote. :P And deleting overloads doesn't need virtual...
View ArticleComment by HolyBlackCat on What's the point of deleted virtual functions?
What stops me from dropping virtual and override from all those deleted overloads? That won't affect the behavior.
View ArticleComment by HolyBlackCat on Cannot use freopen_s function in C++?
Try adding #define __STDC_WANT_LIB_EXT1__ 1 as the first line of the program.
View ArticleAnswer by HolyBlackCat for What's the point of deleted virtual functions?
It appears to be an ABI compatibility tool, to add dummy entries to the vtable.Despite being impossible to call in legal C++, those functions still get entries in the vtable that crash the program when...
View ArticleComment by HolyBlackCat on SQLite3 on C++ not worked
Might wanna delete or unedit your previous question. I almost kneejerk closed this as a duplicate, not realizing you edited the previous one after it got closed.
View ArticleComment by HolyBlackCat on IMG_LoadTexture() fails to load PNG?
Did you build SDL3 yourself?
View ArticleComment by HolyBlackCat on Count of a shared_ptr when managing the same object
Your shared_ptrs don't manage i. Each contains its own copy of i.
View ArticleComment by HolyBlackCat on Which value category does x have in `((struct...
Clang rejects it for me. Maybe yours is treating this as a C file because you're using clang instead of clang++?
View ArticleAnswer by HolyBlackCat for How Does the Left-Hand Side (LHS) of an Assignment...
First of all, "value" isn't "something that evaluates to itself". A value is a meaning associated with the bits representing the object. E.g. if you have int x = 42;, the bits in x represent the number...
View ArticleComment by HolyBlackCat on Why does std::views::take_while() do so many...
It was hoping __attribute__((__pure__)) on the lambda would do something, but alas.
View Article