How can I get the return type of a member function in the following example?
template <typename Getter>
class MyClass {
typedef decltype(mygetter.get()) gotten_t;
...
};
The problem, of course, is that I don't have a "mygetter" object while defining MyClass.
What I'm trying to do is: I'm creating a cache that can use, as it's key, whatever is returned by the getter.
I'm not quite sure what you want, but it seems mygetter
is supposed to be simply any object of type Getter
. Use std::declval
to obtain such an object without anything else (you can only use it for type deduction)
typedef decltype(std::declval<Getter>().get()) gotten_t;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With