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

Flaviu_ 911 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 ?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,540 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,181 Reputation points Microsoft Vendor
    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.