'invoke_result_t': use of dependent type name must be prefixed

Flaviu_ 1,031 Reputation points
2021-04-01T08:39:40.627+00:00

I have a code:

//add any arg # function to queue
template <typename Func, typename... Args>
auto Add(Func&& f, Args&&... args)
{
    //get return type of the function
    using RetType = std::invoke_result_t<Func, Args...>;

and on last line, at compiling time I got:

error C7510: 'invoke_result_t': use of dependent type name must be prefixed with 'typename'

How can I overcome this error ?

Developer technologies C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2021-04-01T09:11:12.753+00:00

    Hi,

    I suggest you could try to change the Conformance mode property value to No: Configuration Properties -> C/C++ -> Language -> Conformance mode = No.

    For more details about /permissive- (Standards conformance),I suggest you could refer to the Doc:/permissive- (Standards conformance)

    And you could add the typename keyword to the declaration to avoid the error.

    Best Regards,

    Jeanine


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.