Quantcast
Channel: User HolyBlackCat - Stack Overflow
↧

Answer 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 Article


Answer 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 Article


Comment 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Comment 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 Article


Comment 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 Article

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 Article

Answer 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 Article

Comment by HolyBlackCat on Are there any remaining differences between member...

@PepijnKramer You mean when using the operator==() notation to call it?

View Article


Comment 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article


Comment 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

Answer by HolyBlackCat for lldb error: Cannot launch a.out: personality set...

personality set failed: Operation not permittedI had this error when trying to use LLDB in Docker. The cryptic error means it tries to disable ASLR and fails at it (GDB also tries and fails, but it...

View Article

Answer by HolyBlackCat for If a global variable is initialized twice...

This is CWG issue 2821.This isn't resolved yet, but CWG has said that the intended resolution is "first initialization begins lifetime, subsequent initialization just modifies the value".

View Article

If a global variable is initialized twice (statically, then dynamically),...

Inspired by this question.We know that global variables with non-constexpr initializers undergo two different "initializations":First, the "static initialization", which zero-initializes them.Second,...

View Article


What is the significance of 'strongly happens before' compared to '(simply)...

The standard defines several 'happens before' relations that extend the good old 'sequenced before' over multiple threads:[intro.races]7 An evaluation A happens before an evaluation B if either(7.1) —...

View Article


Answer by HolyBlackCat for What is the significance of 'strongly happens...

Here's my current understanding, which could be incomplete or incorrect. A verification would be appreciated.First of all, years later after those changes, C++26 has renamed simply happens before to...

View Article

Answer by HolyBlackCat for How to infer whether a global sequence is valid or...

Because if 2 is reordered and it happens before 1Since 1 is sequenced-before 2, 1 happens-before 2 as well. That can't be reversed.the relaxed-store 2 will be synchronized while operation 1 releasedNot...

View Article

Comment by HolyBlackCat on What is `template for` in C++26?

I was like "wait, I've seen a paper that makes vectors work here directly without define_static_array". Turns out it's your paper. :P A shame it didn't get into C++26.

View Article


Answer by HolyBlackCat for MacOS clang compiler issue (Apple clang version...

T() and T{} only zero-initialize the object if the constructor of T is not user-provided (https://eel.is/c++draft/dcl.init.general#9.1).I.e. only if the constructor is either implicitly generated, or...

View Article

Comment by HolyBlackCat on C++ memory order relaxed for a producer and...

@PeterCordes Hmm, this sounds like some non-standard fence semantics. The standard only makes them bless preceding loads in the same thread. Is this some non-standard semantic that nontheless works in...

View Article

Comment by HolyBlackCat on SECONDEXPANSION and implicit rule recursion don't...

Can't reproduce, the first snippet works for me. Make 4.4.1.

View Article

Comment by HolyBlackCat on How to inspect class memory layout in Visual...

Clangd had that for ages. Replace the stock intellisense with that. I bet that's where VS got the inspiration from.

View Article



Answer by HolyBlackCat for Decoupling templated dispatcher

Sadly function templates can't be passed to functions directly, so we have to wrap it in a lambda. And then use a somewhat ugly call syntax:template <int>void fn() {}void dispatcher(auto...

View Article

Comment by HolyBlackCat on Is it possible to restrict variable declaration of...

Is this because you want to avoid accessing the falsey value? Note that the variable is still accessible in the else branch, so you're out of luck even if you figure out how to forbid this.

View Article

Comment by HolyBlackCat on std::invoke_result_t + std::mem_fn does not compile

Please don't omit the standard headers, and add the error message (which should hopefully say what type Field is). This would make the job of whoever answers this much easier.

View Article

Comment by HolyBlackCat on making an invocable concept more accurate with...

@Oersted It's briefly explained in the very first sentence of the answer. If you do std::invocable<..., unique_ptr<int>&>, it tests if something like this is well-formed:...

View Article


Comment by HolyBlackCat on arr[n] type: a reference according to decltype, a...

decltype((...)) is different from decltype(...) only when ... is a variable, because decltype(...) is a special case only for variables. arr[5] isn't one.

View Article

Comment by HolyBlackCat on Reproducing a libc++ optimisation that uses tail...

Turns out that T must be non-POD for its trailing padding to be reusable, supposedly for C compatibility. (This isn't something the C++ standard requires, but something that the Itanium ABI does, I...

View Article

Comment by HolyBlackCat on Can padding of bases or [[no_unique_address]]...

I've figured this out and posted an answer. :)

View Article


Comment by HolyBlackCat on Can padding of bases or [[no_unique_address]]...

@MarcGlisse Not that motivated. :P What did they improve?

View Article


Can padding of bases or [[no_unique_address]] members be used to store other...

The note in [dcl.attr.nouniqueaddr] says:[Note 1: The non-static data member can share the address of another non-static data member or that of a base class, and any padding that would normally be...

View Article

Answer by HolyBlackCat for When is it required to add the types for template...

Classes (which includes structs) have something called injected-class-name in them, which acts as a (somewhat magical) typedef pointing to the class itself:template<std::signed_integral T>struct...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>