Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. use of dependent type name must be prefixed

use of dependent type name must be prefixed

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structureshelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    I have a code:

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

    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 ?

    Greg UtasG L 2 Replies Last reply
    0
    • _ _Flaviu

      I have a code:

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

      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 ?

      Greg UtasG Offline
      Greg UtasG Offline
      Greg Utas
      wrote on last edited by
      #2

      I believe that typename is supposed the be prefixed to tell the compiler that invoke_result_t is defining a type:

      using RetType = std::typename invoke_result_t;

      Robust Services Core | Software Techniques for Lemmings | Articles
      The fox knows many things, but the hedgehog knows one big thing.

      <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
      <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

      _ 1 Reply Last reply
      0
      • Greg UtasG Greg Utas

        I believe that typename is supposed the be prefixed to tell the compiler that invoke_result_t is defining a type:

        using RetType = std::typename invoke_result_t;

        Robust Services Core | Software Techniques for Lemmings | Articles
        The fox knows many things, but the hedgehog knows one big thing.

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        I have tried:

        using RetType = std::typename invoke_result_t;

        but I got: error C2589: 'typename': illegal token on right side of '::'

        Greg UtasG 1 Reply Last reply
        0
        • _ _Flaviu

          I have tried:

          using RetType = std::typename invoke_result_t;

          but I got: error C2589: 'typename': illegal token on right side of '::'

          Greg UtasG Offline
          Greg UtasG Offline
          Greg Utas
          wrote on last edited by
          #4

          Try moving it to the front:

          using RetType = typename std::invoke_result_t;

          This[^] may be of help.

          Robust Services Core | Software Techniques for Lemmings | Articles
          The fox knows many things, but the hedgehog knows one big thing.

          <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
          <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

          _ 1 Reply Last reply
          0
          • Greg UtasG Greg Utas

            Try moving it to the front:

            using RetType = typename std::invoke_result_t;

            This[^] may be of help.

            Robust Services Core | Software Techniques for Lemmings | Articles
            The fox knows many things, but the hedgehog knows one big thing.

            _ Offline
            _ Offline
            _Flaviu
            wrote on last edited by
            #5

            I already did:

            using RetType = typename std::invoke_result_t;

            Result: error C2760: syntax error: unexpected token '<', expected ';'

            Greg UtasG 1 Reply Last reply
            0
            • _ _Flaviu

              I have a code:

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

              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 ?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              See std::result_of, std::invoke_result - cppreference.com[^], which suggests the word typename goes before std::invoke_result_t. Although the discussion is less clear than it could be.

              1 Reply Last reply
              0
              • _ _Flaviu

                I already did:

                using RetType = typename std::invoke_result_t;

                Result: error C2760: syntax error: unexpected token '<', expected ';'

                Greg UtasG Offline
                Greg UtasG Offline
                Greg Utas
                wrote on last edited by
                #7

                See "Helper types" on this page[^]. It looks like invoke_result_t is itself a type alias. Try std::invoke_result without the _t.

                Robust Services Core | Software Techniques for Lemmings | Articles
                The fox knows many things, but the hedgehog knows one big thing.

                <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups