I wanted to know that this is possible to make an erased type that conforms to a trait like this one :
template<class T>
using read_t = std::conditional_t<true,
decltype(std::declval<T>().Read(uint16_t{})),
std::integral_constant<uint8_t (T::*)(uint16_t), &T::Read>>;
and use it like this ?
using any_readable_t = any<read_t>;
auto test(any_readable_t &r) -> uint8_t {
return r.Read(0);
}
Without any external library, there's a lot of work that needs to be done to achieve what you want. Using Louis Dionne's
dyno
: