I want to check if rfl::to_view() can be applied to a variable of type T, but the following code fails to compile:
template<class T>
void FailedToCompile(T const& t) {
if constexpr (requires { rfl::to_view(t); }) {
}
}
int main() {
std::string s = "hello";
FailedToCompile(s);
}
As a workaround, I have to use std::is_aggregate_v<T> for the check instead.
Would it be possible to add a concept constraint requiring rfl::to_view to only be applicable when T satisfies std::is_aggregate_v<T>? That way, the if constexpr (requires { rfl::to_view(t); }) condition would work as expected.
I want to check if
rfl::to_view()can be applied to a variable of typeT, but the following code fails to compile:As a workaround, I have to use
std::is_aggregate_v<T>for the check instead.Would it be possible to add a concept constraint requiring
rfl::to_viewto only be applicable whenTsatisfiesstd::is_aggregate_v<T>? That way, theif constexpr (requires { rfl::to_view(t); })condition would work as expected.