P2996 - type_of and std::meta::info
Opened this issue · 0 comments
It's sometimes the case that whilst manipulating std::meta::info with ranges that the underlying type of the std::meta::info is required, for example: to do some transformations on the underlying type.
It seems that type_of should be the right tool for the job, but that's not the case and instead substantial effort is required. The following is an example of how to lifting to type from std::meta::info can be achieved.
template <class R>
consteval auto invoke(auto fn, std::meta::info m) {
return value_of<R>(reflect_invoke(^fn, {substitute(^meta, {reflect_value(m)})}));
}
Simple example of filter with test_test or, more generic, conversion to type:
- test_type - https://godbolt.org/z/9cMa9xnPn
- std::meta_info -> T - https://godbolt.org/z/4fMjKjK7o
Maybe there is a better way or maybe type_of
should be made to work in such case or maybe there should be some utility such as invoke
to make that simpler? Not sure, just wanted to raise it here as it's not trivial and/or clear, at least for me, what's the canonical way to do it?