Why 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 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 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 ArticleAnswer by HolyBlackCat for Why is std::floor not found when including in...
<cmath> declares things in namespace std. <math.h> declares things in the global namespace. (Same for all other C standard library headers.)Cppreference (and the standard) says that...
View ArticleComment by HolyBlackCat on Are variables formally a compile-time concept?
@463035818_is_not_an_ai That is because int x; is spelled twice in the source code. If it's spelled once, then under a certain interpretation it's the same variable.
View ArticleAnswer by HolyBlackCat for What do each memory_order mean?
Firstly...Things to ignore:memory_order_consume - apparently no major compiler implements it, and they silently replace it with a stronger memory_order_acquire. Even the standard itself says to avoid...
View ArticleAnswer by HolyBlackCat for What is the category of iota_view iterator?
In addition to what the other answer says, I'd like to point out that there are two parallel iterator classification systems now.You're looking at the old-style iterator category, but it doesn't make...
View ArticleAnswer by HolyBlackCat for pointer-to-member syntax difference in g++ 13...
This is invalid C++. This works for you because MinGW GCC implicitly enables -fms-extensions (imitating MSVC's non-standard features).I doubt this is new in GCC 14. I don't have a MinGW GCC 13 at hand...
View ArticleAnswer by HolyBlackCat for Only copiable type not accepted in msvc...
TL;DR: This is a poorly written class.Copyable classes shouldn't actively resist moving, even if they don't want to have any custom move behavior.Instead they should let moving fall back to copying,...
View ArticleAnswer by HolyBlackCat for How to transform a world space position to a...
P == R * localP + CP - C == R * localP + C - CP - C == R * localPinv(R) * (P - C) == inv(R) * R * localPinv(R) * (P - C) == localP
View ArticleComment by HolyBlackCat on Is part of youtube-api search server not working...
Please don't add [tags] to the title. We already have the actual tags.
View ArticleComment by HolyBlackCat on In a false `if constexpr` branch outside of a...
@NathanOliver if constexpr has two unrelated effects. Yes, this one you linked doesn't apply, but there's another one that I explained in my question with all the relevant quotes, that does apply.
View ArticleComment by HolyBlackCat on In a false `if constexpr` branch outside of a...
@cigien It's not as much about it being "mine", just felt weird to have the answer be written in what is essentially third person.
View ArticleComment by HolyBlackCat on how to generate gtags files for standard c++...
I'm curious why you're using gtags instead of something like Clangd.
View ArticleComment by HolyBlackCat on Spaceship comparison contradicts equality operator
Why do people always try to do this (make <=> compare distance to the origin)? The only ordering that makes sense is the lexicographical one. If you're gonna insert your points into a std::set,...
View ArticleComment by HolyBlackCat on using clang with tdm-g++?
Install MSYS2, it has everything you could want: builds of Clang that use MinGW by default (with libstdc++ or libc++), a version of GCC that isn't oudated, etc.
View ArticleComment by HolyBlackCat on Variable traceability in C++
I voted to reopen, but I honestly have no idea what you're trying to ask. Why can't you just make some maps to store those dependencies?
View ArticleComment by HolyBlackCat on lldb-dap exception 0x80000003 under Windows 11 /...
LLDB-DAP is a bit wonky. If it doesn't work for you, try CodeLLDB.
View ArticleWhat 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 ArticleComment by HolyBlackCat on Copy constructor best fit order
Seemingly using is special-cased to not inherit copy constructors. Base2(const Base1&) isn't a copy constructor because the parameter type is different.
View ArticleComment by HolyBlackCat on Clang: compile_commands.json "file" - attribute -...
A relative directory used to cause issues. Clangd would randomly change its current directory and suddenly stop working. Maybe that got fixed eventually, I don't know.
View Article