Hacker News new | ask | show | jobs
by Conscat 1009 days ago
Clang has a statement attribute `[[clang::always_inline]]` that automates this at a call site, but GCC only has a function attribute for it. You could wrap the function in a `[[gnu::flatten]]` function that takes the callable as a non-type template parameter in C++20 to do this, though, but that could be more aggressive than what you want. It also won't work for operators as easily as this.

You can already expand macros at call site in any major C++ editor, so why not functions as well?

I would like this mainly just for making source exploration easier. Visual Studio and Clion have a "peek" feature that does something similar, but as a purely UI element, but Emacs' implementation of peek from LSP works much worse.

1 comments

Correction, I actually just tried this. The wrapper does not work in GCC, but it does in Clang. https://godbolt.org/z/d3jMo36WY