After surveying the P2996R2 paper I believe this is not covered.
I am working on building the draft proposal further but happy to collect more feedback here while I work on it... ]
Draft for "Attributes introspection"
Attributes are used to great extent and there likely will be attributes added as the language evolve.
What is missing now is a way for generic code to look into the attributes related to an entity.
A motivating example is following
#include <functional>
[[nodiscard]] bool foo(int i) { return i % 2 ; }
template <class F, class... Args>
constexpr std::invoke_result_t<F, Args...> logInvoke(F&& f, Args&&... args) {
// Do some extra work, log the call
// ...
// Fwd call
return std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
}
int main() {
foo(0); // Warning on discarded return
logInvoke(foo, 0); // No warning on discarded return
}
Other examples of wrapping around callables can be found, whether by closure or explicitly registering callbacks for dispatch, etc.
The proposal here is to introduce a `declattr` keyword to look into attributes bound to an entity, the form would be likely equivalent to how `decltype` or `declval` are used.