I am trying to get the return type of a function with const/non const overloads.
struct TestClass {
const int* getPtr() const { return ptr; }
int* getPtr() { return ptr; }
private:
int* ptr;
};
using return_ptr_type = typename std::invoke_result<decltype(&TestClass::getPtr), TestClass>::type;
static_assert(std::is_same<return_ptr_type, int*>::value);
Compiler complains that it cannot resolve address of overloaded function. I understand why this happens, but not how to fix it.
Note: I see other questions on stack overflow on how to resolve between overloads, but they deal with overloads with different function arguments, not const overloads.