Thanks, nice article. My usual workaround is using a bunch of operator()'s on the value level for that, and then decltype-and-declval-ing all the way through.
This is the kind of thing I guess I get why it could be useful but also might make me lose my shit if I ever saw it in an actual codebase I have to work on.
I don't think many of us want to duplicate the value-world facilities in the type-world. Converting types to values and dealing with them with reflection functions is likely the future, even though this means we need to sprinkle [: :] and other tricks here and there.
18
u/Top-Mycologist-5460 Sep 14 '26
Thanks, nice article. My usual workaround is using a bunch of operator()'s on the value level for that, and then decltype-and-declval-ing all the way through.
31
u/jdehesa Sep 14 '26
This is the kind of thing I guess I get why it could be useful but also might make me lose my shit if I ever saw it in an actual codebase I have to work on.
16
u/13steinj Sep 14 '26
"Why does the author sound familiar to me?"
searches name of website.
Of course, it's Ben Deane.
14
u/UnusualPace679 Sep 14 '26
I don't think many of us want to duplicate the value-world facilities in the type-world. Converting types to values and dealing with them with reflection functions is likely the future, even though this means we need to sprinkle
[: :]and other tricks here and there.3
u/GabiTheProgrammer Sep 14 '26
Very nice read.
-1
u/zerhud Sep 14 '26 edited Sep 15 '26
We can
template<typename t> struct _type_c {
t operator +() const ;
};
template<typename t> constexpr auto type_c = _type_c<t>;
template<typename t> concept is_type_c = … ;
template<template<typename…>typename t>
struct _tmpl_c{
constexpr auto operator()(is_type_c auto&&… args) {
return type_c<t<decltype(+args)…>>;
}
};