4 ms·
I'm not a C++ expert but I believe it is not possible in current C++ to implement a pointer type that will cause a compiler error when it is sent to another thr
by xmcqdpt2 3y ago
I'm not a C++ expert but I believe it is not possible in current C++ to implement a pointer type that will cause a compiler error when it is sent to another thread.
- PaulDavisThe1st 3y agoThat's almost certainly true, but first you have to define "send to another thread"
- 3836293648 3y agostd::jthread?
- jandrewrogers 3y agoInteresting thought experiment. While I haven’t tried it, one half-baked idea that comes to mind is disable both copy and move for the pointer and instantiate the type in C++ thread-local storage. Not that I ever would.
- xmcqdpt2 3y agoIt is interesting! I experimented with creating a bad borrow checker for Java using annotations from https://checkerframework.org/ https://checkerframework.org/ It supports some level of substructural types using must-call annotations, https://checkerframework.org/manual/#resource-leak-checker https://checkerframework.org/manual/#resource-leak-checker