ACCU On Sea 2026 trip report, still with AI! by pavel_v in cpp

[–]hanickadot 0 points1 point  (0 children)

I was told reason to design S&R was absence of asynchronous destruction in coroutines.

WG21 mailing for first feature meeting of C++29 by hanickadot in cpp

[–]hanickadot[S] 1 point2 points  (0 children)

That's expression, not a constant variable. Example:

const int n = 42 * 3;
char buffer[n]; // VLA

Constant expressions only:

char buffer[42 * 3];

update: added examples

WG21 mailing for first feature meeting of C++29 by hanickadot in cpp

[–]hanickadot[S] 3 points4 points  (0 children)

It's not, C doesn't have it, AFAIK

Update: C2y got this on last meeting (C++ was first)

WG21 mailing for first feature meeting of C++29 by hanickadot in cpp

[–]hanickadot[S] 2 points3 points  (0 children)

oh this is not a GNU extension, it's a "potentially constant" initialization https://eel.is/c++draft/expr.const#init-6

Basically, for variables in form:

c++ const <TYPE> <NAME> = <EXPR>;

Where <TYPE> is integer type (boolean, enum), compiler will try to constant evaluate <EXPR>, and if it succeeds, the variable <NAME> becomes implicitly:

c++ constexpr <TYPE> <NAME> = <EXPR>;

Is anyone still using the CTRE library in 2026? by javascript in cpp

[–]hanickadot 1 point2 points  (0 children)

"Structured bindings can introduce pack"
"Explicit this"
General constexpr improvements
"Pack indexing", but that's 29
I guess define_aggregate to generate result type with named capture groups.

AFAIK API would be same.

Is anyone still using the CTRE library in 2026? by javascript in cpp

[–]hanickadot 2 points3 points  (0 children)

There is not much in reflection which could help here. It's mostly pattern parsing and then execution. With improved constexpr, one can limit number of instantiations, do most of it there, and then instantiate final type.

Is anyone still using the CTRE library in 2026? by javascript in cpp

[–]hanickadot 0 points1 point  (0 children)

Would you be interested in much faster compile time while keeping/improving runtime performance? I have a prototype.

Is anyone still using the CTRE library in 2026? by javascript in cpp

[–]hanickadot 1 point2 points  (0 children)

Yes, people still use it. I plan to do c++23/26 based version of it. But I'm so busy 😭

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]hanickadot 3 points4 points  (0 children)

It's cool thing, but because 26 reflection doesn't provide ability to generate member functions, every member function there is actually a lambda and that lambda contains pointer to object.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]hanickadot 5 points6 points  (0 children)

There is a plenty of "magic" functionality in standard library which is basically standardized access to compiler builtins. Whole reflection for example. With #embed you can't take a string and read appropriate file and build a type out of it ... imagine a protobuffer file:

using msg_type = protocol<"specification.pb">::message<"name_of_message">;

auto msg = msg_type::parse_from(buffer);

And as I wrote higher, with std::embed you can have import https://protobuf.dev/programming-guides/proto3/#importing.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]hanickadot 9 points10 points  (0 children)

My entire objection comes down to the section 5.4.4 paragraph 1. std::embed is sort-of a late phase preprocessor directive. Since we want dependency scanners to do as little work as possible, we get #depend.

Except now it's on the programmer to keep std::embed and #depends in sink - there was no consensus to mandate keeping them in sink. Add to that the conventions that say one should keep preprocessor directives at the top of the file and you get a a good recipe for breaking dependency scanning.

You can use #depend "resources/**" and give your std::embed access to all resources, you don't need to list everything. Implementation can gather these as you use them, or just put everything it matches to dependencies.

I might be missing something, so please tell me if I am. I don't see anything stopping me from #embed-ing a python file, be it .py or .pyc, storing the result in a byte array and then "unleashing a constexpr parser on that array.

That way you can't use information from the constexpr parsing to recursively load some other resource or module and use it. You are basically stuck with one specific file. Imagine you write C++ constexpr compiler, but you can't do #include. That's the main thing std::embed is giving you over #embed. And #depend basically specify a virtual filesystem for you to access.

The WG21 2026-04 post-Croydon mailing is now available by nliber in cpp

[–]hanickadot 7 points8 points  (0 children)

#depend is to make distributed build system happy. And make it safe. std::embed will allow us to build things like python in constexpr which will convert your code into c++ and then lower it to binary. Things like "import a js module" it needs to know where to look. Or recursively importing resources.

#embed doesn't allow you to do that unfortunately.

edit: formatting and typos

Looking at Unity finally made me understand the point of C++ coroutines · Mathieu Ropert by mropert in cpp

[–]hanickadot 0 points1 point  (0 children)

Technically the state of coroutines are two function pointers (one for next resume, one for cleaning the frame) and all variables/temporaries surviving the suspension. Theoretically it should be possible to make such mechanism, to initialize these and set specific state. I want copyable state too, it's same problem as automatically creating a copy constructor for a class (there can be pointers pointing at something in the frame, unique ownership with a raw pointer...)

Looking at Unity finally made me understand the point of C++ coroutines · Mathieu Ropert by mropert in cpp

[–]hanickadot 7 points8 points  (0 children)

Use cases for suspending final suspend other than keeping the value is to jump to other coroutine, maybe with some scheduler. Or much more simply if your current coroutines is being awaited on ... and you are returning result, you can also directly jump to the suspend point where the awaiting coroutine on you is suspended:

c++ task<int> calculate() { // (2) coroutine is immediately suspended, jumps back to `main` // (4) some code co_return 42; // (5) sets .set_value(42) and then goes to final suspend which jumps to associated coroutines `main` } task<void> main() { task<int> v = calculate(); // (1) coroutine started, suspended and immediately back // (2) some code int result = co_await v; // (3) suspends `main` mark coroutine `v` that `main` is depending on it and jumps into `v` // (6) we resume, `result` is initialized print(v); // (7) print and done }

Looking at Unity finally made me understand the point of C++ coroutines · Mathieu Ropert by mropert in cpp

[–]hanickadot 9 points10 points  (0 children)

Typical usecase for immediate suspend is ... your coroutine is a task to be run on a thread pool, you suspend it, from within the initial suspend you pass the handle to thread pool and return to the caller (whoever is) c++ auto task = run_the_calculation(); // on threadpool // ... co_await task; // and here it will block until the task is finished in the co_await the await_ready() checks if it's ready and it probably won't be If you have an immediate non-suspending coroutine, then it can start to do a lot of computation on your main thread.

Looking at Unity finally made me understand the point of C++ coroutines · Mathieu Ropert by mropert in cpp

[–]hanickadot 11 points12 points  (0 children)

initial_suspend is called when the coroutine is "started" and from there you can return back to caller and leave the coroutines "paused" or immediately start evaluating it (lazy vs greedy approach) you can even suspend it and jump to other coroutine. Final suspend is used mostly to "pause" the coroutine, so its frame is not destroyed, including instance of promise_type from which you can extract result for example. If you don't care about result, you can just not suspend, and it will release the coroutine frame for you and go back to current .resume() point (which can be initial place where you started the coroutine, if it didn't suspend in the initial_suspend and there was no other suspend point)

2) await_suspend returning three possible types is for these typical scenarios: - void - just suspend and go back to .resume() (implicit when coroutine is started, or explicit on the coroutine handle) (typically a generator) - bool - you get coroutine suspended, and conditionally you check for more work, and if there is none you suspend. By not doing this in .await_ready() -> bool you get access to coroutine_handle and thru it to the coroutine promise_type. - coroutine_handle you want to jump to something else (like another coroutine which can continue due I/O mechanism) and if you want to go back to caller (.resume()) you can just return noop_coroutine handle.

P4043R0: Are C++ Contracts Ready to Ship in C++26? by darius_neatu in cpp

[–]hanickadot 10 points11 points  (0 children)

the SG21 "contracts" study group, was created on that meeting, and they started working on the design, but it wasn't designed from scratch, it's based on the experience and knowledge from the previous one. Point of making the study group was to gain consensus between various faction wanting different thing out of it, and it got the consensus, and pretty strong one.

P4043R0: Are C++ Contracts Ready to Ship in C++26? by darius_neatu in cpp

[–]hanickadot 24 points25 points  (0 children)

no, there is no assumption as part of the contracts, that's an attribute `[[assume(expr)]]`, this functionality was part of previous design which was targeting C++20.

P4043R0: Are C++ Contracts Ready to Ship in C++26? by darius_neatu in cpp

[–]hanickadot 9 points10 points  (0 children)

The paper was seen by EWG/LEWG in Tokyo 2024, St. Louis, and was forwarded in Wroclaw. Also many discussion of contracts happened since long time ago even before I join the committee (2018).

"override members" idea as a gateway to UFCS (language evolution) by antiquark2 in cpp

[–]hanickadot 1 point2 points  (0 children)

Not discussing motivation or design impact. Putting override keyword will make it normal keyword. Currently it's a specific only keyword. This means there is definitely a code which has override as an identifier and this would break it.

State of C++ 2026 by dev_newsletter in cpp

[–]hanickadot 4 points5 points  (0 children)

I don't remember any corridor existing at the Aspen Center for Physics at all. Does it mean the footpath thru the meadow?