Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8731441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:14:23+00:00 2026-06-13T09:14:23+00:00

For the example template <typename T> void function(T&& arg) Can somebody explain in detail

  • 0

For the example

template <typename T>
void function(T&& arg)

Can somebody explain in detail how does it end that function signature becomes T& for lvalues and T&& for rvalues passed in ? I know that somehow(standard line needed) T -> T& in the case of lvalues and T -> T in case of revalues and then by combining & and && it results lvalue/rvalue reference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:14:25+00:00Added an answer on June 13, 2026 at 9:14 am

    The rule is found in section 8.3.2p6.

    If a typedef, a type template-parameter, or a decltype-specifier denotes a type TR
    that is a reference to a type T, an attempt to create the type “lvalue reference to cv TR” creates the type “lvalue reference to T“, while an attempt to create the type “rvalue reference to cv TR” creates the type TR.

    Or in tabular form:

    TR   R
    
    T&   &  -> T&  // lvalue reference to cv TR -> lvalue reference to T
    T&   && -> T&  // rvalue reference to cv TR -> TR (lvalue reference to T)
    T&&  &  -> T&  // lvalue reference to cv TR -> lvalue reference to T
    T&&  && -> T&& // rvalue reference to cv TR -> TR (rvalue reference to T)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a function: template <typename T> void doIt( T*& p )
C++0x shows an example of using std::forward : template<class T> void foo(T&& arg) {
Example #include <vector> #include <cassert> template <typename Cont, typename... Rest> void f(Cont& c, Rest&...
I currently have a function template, taking a reference, that does something in essence
I have the following template function which prints to cout: template <typename T> void
Consider the following example: struct Scanner { template <typename T> T get(); }; template
I have a base.html template that contains a list of links. Example: <div id=sidebar1>
I read some XSLT examples and found that code: <xsl:apply-template select=@*|node()/> What does that
How can I specialize or overload function func so that specialization handles all instances
Assume that I have a boost::function of with an arbitrary signature called type CallbackType

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.