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 8428299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:00:55+00:00 2026-06-10T05:00:55+00:00

What are the cases when std::forward is not needed? It is used to wrap

  • 0

What are the cases when std::forward is not needed? It is used to wrap inner function argument which is templated-rvalue (that is, it can be lvalue or named-rvalue). Like in:

template<class T>
void outer(T&& t) { 
    inner(std::forward<T>(t)); 
}

I am guessing one case is when inner function parameters are passed by value. Are there other cases? I’ve got this question when I was writing std::begin(std::forward<Ct>(ct)) where Ct is templated-rvalue-ref.

EDIT about possible duplicate

If I remember correctly, this is 3rd attempt to close this 4yr old question as duplicate by some newbie who don’t understand the question.

“Advantages of using forward?” and “When not to use std::forward with r-values?” are very different questions. First is introduction into r-values for beginners and second is discussion of perfect forwarding for advanced C++ user. I am author of meta-template library and lambda library, who don’t need verbose description of basics. Information in answer is very different from other question.

  • 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-10T05:00:56+00:00Added an answer on June 10, 2026 at 5:00 am

    I am answering to my own question as I didn’t get satisfactory answer so far.
    If I will get even small improvement/addition to this – I will chose your answer as accepted.

    In general std::forward will be beneficial with inner function if effect of perfect forwarding will be achieved. Otherwise it is superfluous.

    Use std::forward to wrap inner function arg only if any of below is true:

    • inner function parameter is templated-rvalue-ref (now called “forwarding reference”);
    • inner function has multiple overloads which differentiate based on parameter r/l-valueness;
    • inner function has multiple overloads which differentiate lvalue parameter based on constness;
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen some special cases where std::rotate could be used or a combination with
Question Synopsis Given a std::vector<T> , how can I create a view that exposes
In most cases, I've been setting an event class handler that will apply to
Are there any cases in which anything more than a linear speed increase comes
In VS2010 std::forward is defined as such: template<class _Ty> inline _Ty&& forward(typename identity<_Ty>::type& _Arg)
How should the following cases be handled: I have some geometrical storage, which is
Let's say you want to write a function which gets passed an opaque handle
The C++ std algorithms define a number of algorithms that take an input and
What's the difference between the following two cases? std::pair<int,std::string> example_1 (std::make_pair (1,foo)); int value_1
std::auto_ptr is not allowed to be stored in an STL container, such as std::vector

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.