c++operatorsc++17member-functionsinvoke-result

invoke_result with member (operator[]) function


How do I call invoke_result correctly for a member function? Or specifically for an operator member function. I tried std::invoke_result<T::operator[], size_type> to no success. What would be the correct syntax in this case?


Solution

  • Don't. Use decltype(std::declval<T&>()[size_type{}]) or something similar (adjust the value category and the cv-qualification as needed).

    invoke_result is for when you have an invocable/callable object. You don't have one, so don't try to hammer square pegs into round holes.