Readit News logoReadit News
rovingeye commented on C++ Modules Are Here to Stay   faresbakhit.github.io/e/c... · Posted by u/faresahmed
direwolf20 · 2 months ago
It's unusual. Some, unusual, style guides require it. It's useful in some cases, even necessary in some which is why it was introduced, but not for simple "int"
rovingeye · 2 months ago
it's literally the exact same thing. We use trailing return types to be consistent across the language.
rovingeye commented on C++ Modules Are Here to Stay   faresbakhit.github.io/e/c... · Posted by u/faresahmed
whobre · 2 months ago
> auto main() -> int {

Dude…

rovingeye · 2 months ago
This has been valid C++ since C++ 11
rovingeye commented on Closures as Win32 Window Procedures   nullprogram.com/blog/2025... · Posted by u/ibobev
pjmlp · 3 months ago
rovingeye · 3 months ago
It looks like you missed the part where you "move the context into the lambda body via capture specifier."
rovingeye commented on How well do you know C++ auto type deduction?   volatileint.dev/posts/aut... · Posted by u/volatileint
jjmarr · 3 months ago
I don't understand why anyone would use auto and a trailing return type for their functions. The syntax is annoying and breaks too much precedent.
rovingeye · 3 months ago
Consistency (lambdas, etc.)
rovingeye commented on Closures as Win32 Window Procedures   nullprogram.com/blog/2025... · Posted by u/ibobev
userbinator · 3 months ago
This somewhat reminds me of the old MakeProcInstance mechanism in Win16, which was quickly rendered obsolete by someone who made an important realisation: https://www.geary.com/fixds.html

Another seemingly underutilised feature closely related to {Get,Set}WindowLong is cbClsExtra/cbWndExtra which lets you allocate additional data associated with a window, and store whatever you want there. The indices to the GWL/SWL function are quite revealing of how this mechanism works:

https://learn.microsoft.com/en-us/windows/win32/api/winuser/...

rovingeye · 3 months ago
All my window classes uses cbWndExtra, and I leave GWLP_USERDATA for the user who is creating windows.
rovingeye commented on Closures as Win32 Window Procedures   nullprogram.com/blog/2025... · Posted by u/ibobev
pjmlp · 3 months ago
I mean using a static C++ lambda that moves the context into the lambda body via capture specifier.

C++ lambdas are basically old style C++ functors that are compiled generated, with the calling address being the operator().

rovingeye · 3 months ago
That doesn't sound like a valid wndproc
rovingeye commented on Closures as Win32 Window Procedures   nullprogram.com/blog/2025... · Posted by u/ibobev
pjmlp · 3 months ago
You kind of can, that is one of their design points, naturally you need to move the context into the body and know what to cast back from.

I guess I need to prove a point on my Github during next week.

rovingeye · 3 months ago
I assume by "move the context into the body" you mean using GetWindowLongPtr? Why not just use a static wndproc at that point?
rovingeye commented on Closures as Win32 Window Procedures   nullprogram.com/blog/2025... · Posted by u/ibobev
ack_complete · 3 months ago
There's an annoying corner case when using SetWindowLongPtr/GetWindowLongPtr() -- Windows sends WM_GETMINMAXINFO before WM_NCCREATE. This can be worked around with a thread local, but a trampoline inherently handles it. Trampolines are also useful for other Win32 user functions that don't have an easy way to store context data, such as SetWindowsHookEx(). They're also slightly faster, though GetWindowLongPtr() at least seems able to avoid a syscall.

The code as written, though, is missing a call to FlushInstructionCache() and might not work in processes that prohibit dynamic code generation. An alternative is to just pregenerate an array of trampolines in a code segment, each referencing a mutable pointer in a parallel array in the data segment. These can be generated straightforwardly with a little template magic. This adds size to the executable unlike an empty RWX segment, but doesn't run afoul of any dynamic codegen restrictions or require I-cache flushing. The number of trampolines must be predetermined, but the RWX segment has the same limitation.

rovingeye · 3 months ago
I wasn't aware of the thread local trick, I solve this problem by not setting WS_VISIBLE and calling SetWindowPos & ShowWindow after CreateWindow returns (this solves some other problems as well..)
rovingeye commented on State of Terminal Emulators in 2025: The Errant Champions   jeffquast.com/post/state-... · Posted by u/SG-
usrbinbash · 4 months ago
> So convenient!

Running in tmux, marking anything on my terminal immediately puts it into the tmux buffer, without me having to click anything on the keyboard. Pressing middle-mouse pastes it.

THAT is convenience.

rovingeye · 4 months ago
I have that turned on in Windows Terminal but still use ctrl+c because it's how all other software works
rovingeye commented on Zed is now available on Windows   zed.dev/blog/zed-for-wind... · Posted by u/meetpateltech
rovingeye · 5 months ago
The windowing is pretty broken if you use system scaling https://github.com/zed-industries/zed/issues/40272

u/rovingeye

KarmaCake day43October 9, 2023View Original