Quantcast
Channel: User HolyBlackCat - Stack Overflow
↧

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


Overloaded `&&`/`||` 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 Article


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

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

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 Article


Image may be NSFW.
Clik here to view.

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

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

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


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


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

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 Article

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

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


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

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


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

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


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

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

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

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


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


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

Comment by HolyBlackCat on Why ternary operator cannot be used for this...

"does it mean the ternary operator is evaluated as a separate part" Yes, and in general the way (sub)expressions are evaluated doesn't take into account the context they appear in.

View Article

Comment by HolyBlackCat on Is std::hardware_destructive_interference_size...

I don't know much about, but I remember people complaining about them being constexpr, because supposedly they can only be determined properly at runtime.

View Article

Comment by HolyBlackCat on pointer-to-member syntax difference in g++ 13...

Doesn't work in GCC 14 either: gcc.godbolt.org/z/P5haG1Meq This is invalid C++ either way, non-static member functions must be either called or have their address taken on use.

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

Comment by HolyBlackCat on How are datatypes initialized?

Magic. If you're making classes, you can customize how they are initialized, but int isn't a class, it's built into the language.

View Article


Comment by HolyBlackCat on How to Use Clangd correcly without compile from...

Normally clangd works without any compilation, but I don't know how modules affect this. They are still pretty new and half-baked.

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 Does the standard require `operator->()` to be...

It's relatively simple to implement -> for iterators that return by value from *. You just return a proxy by value from -> that contains the value and also overloads its own -> to return a...

View Article


Comment by HolyBlackCat on GLB model renders incorrectly?

Stackoverflow doesn't really work for those kinds of questions (debugging large programs). It's more for explaining specific language features or short pieces of code. You could try asking e.g. on...

View Article


Comment by HolyBlackCat on I got error after linking GLFW library using Makefile

This is typically caused by using x32 libraries with x64 compiler or vice versa. Either find a different version of glfw matching your compiler, or better replace w64devkit with MSYS2, because that...

View Article

Comment by HolyBlackCat on A class has many public functions; after moving...

You don't have to write new functions in the derived class. You can use public: using Foo::some_func; to make the inherited protected functions public. Or alternatively consider the good ol'...

View Article

Comment by HolyBlackCat on `return type is incomplete` error for a class ,...

This typically happens due to circular includes.

View Article

Comment by HolyBlackCat on Assignment in (else) if statement triggers warning...

Correct about what? Yes, one i hides another. But compilers are free to warn or not warn on anything they want.

View Article



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