Comment 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 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 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 Are there any remaining differences between member...
@PepijnKramer You mean when using the operator==() notation to call it?
View ArticleComment by HolyBlackCat on Why is the member of object expression an xvalue...
@dhruv I never found those definitions (in terms of movability and identity) satisfying, especially the "identity" part. I don't consider those "the" definitions. Having or not having "identity" feels...
View ArticleAnswer by HolyBlackCat for Does the type information of an object also take...
This information isn't stored at runtime (except for polymorphic types, i.e. the classes with virtual functions; for those look up "RTTI" and "vtables").It is baked into the generated instructions....
View ArticleComment by HolyBlackCat on std::norm gives two different results (One for...
Try with -ffp-contract=off.
View ArticleComment by HolyBlackCat on Is there a bug in GCC or did I invoke undefined...
Yep, looks like a GCC bug to me. Should probably be reported, if no one did yet.
View ArticleComment by HolyBlackCat on Is visual studio completely standard conformant...
The function parameter is not a temporary, me thinks.
View ArticleComment by HolyBlackCat on Constexpr recursive function type decuction with...
If you do actually need the return type deduction (do you?), pass the string in the template parameter: stackoverflow.com/a/68024633/2752075
View ArticleComment by HolyBlackCat on MSVC calling deleted destructor when wrapping...
Looks like another MSVC bug, I'd report it and move on.
View ArticleComment by HolyBlackCat on Can I create a member function template to return...
std::any as the map element. Or std::unique_ptr<Base> where each Wire<T> inherits from a non-template Base.
View ArticleAnswer by HolyBlackCat for Type trait for enum member value
Starting from C++20, just make a concept:template <typename T>concept EnumWithNone = T::None == T(0);Errors in concepts (such as the missing ::None) silently return false instead of causing a...
View ArticleAnswer by HolyBlackCat for Buffer of chars, unsigned chars or a void* - do we...
Question 1 - is it UB to pass a char array as an argument for placement new?It's not UB by itself, but if that array can't "provide storage" (char array can't), then the array will have its lifetime...
View ArticleComment by HolyBlackCat on How to get filesystem library to work in compiled...
Alan Birtles is right, this is a wrong-dll-in-path issue. See How to debug DLL issues in MinGW?.
View ArticleComment by HolyBlackCat on What is "[core] language undefined behavior" as...
@463035818_is_not_an_ai Practically, buffer overflow in user code and in standard library may be handled by the compilers the same way. But only the former is called "UB". The standard library in not...
View Article