Open ricejasonf opened 7 years ago
I don't understand what you are requesting. Could you show a concrete example of what type_transform will do?
Like hana::transform
but for hana::type
:
#include <boost/hana.hpp>
namespace hana = boost::hana;
template <typename T, typename F>
constexpr auto type_transform(hana::basic_type<T>, F f) {
return decltype(hana::typeid_(f(std::declval<T>()))){};
}
int main() {
constexpr auto foo = hana::type_c<hana::tuple<int, char, double>>;
static_assert(type_transform(foo, hana::back) == hana::type_c<double>);
}
I'd like to double-down and suggest that hana::type
be a Functor
.
This would not be unlike hana::experimental::types
' implementation as a Functor
.
Consider a convenience function to perform operations modifying the contained type in a
hana::type
without unwrapping it and wrapping it again. Consider the following example:Note: It's important that it strips qualifiers since many functions possibly return references.
Possible Implementation (as discussed in Gitter):