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

  • Home
  • SEARCH
  • 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 6350415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:48:19+00:00 2026-05-24T21:48:19+00:00

Perfect forwarding is great and all. But what do I do if I want

  • 0

Perfect forwarding is great and all. But what do I do if I want to not perfectly forward and instead just overload, on something that happens to be a templated type?

template<typename T> void foo(T&& ref);
template<typename T> void foo(const T& ref); 

Won’t work because the first overload will invoke perfect forwarding. I’d really like behaviour very similar to if the first was a normal lvalue reference- where T will always be a value type.

  • 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-05-24T21:48:21+00:00Added an answer on May 24, 2026 at 9:48 pm
    #include <type_traits>
    
    template<typename T>
    typename std::enable_if
    <
        !std::is_reference<T>::value,
        void
    >::type
    foo(T&& ref) {}
    
    template<typename T> void foo(const T& ref) {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It works perfect in all major browsers, but not in IE7. The Java script
I understand that, without R-value references, perfect forwarding in C++ would be impossible. However,
This seems to make perfect sense, but it is not working. I seem to
Everything before was perfect... but... Today something happened to my License checker (without touching
I think everything is perfect in the code but I'm not able to receive
Pixel Perfect https://addons.mozilla.org/en-US/firefox/addon/pixel-perfect/ Is not working any more on FF6 and seams that they
I have created a perfect skin detector, but it detects ALL skin. What are
Possible Duplicate: make_unique and perfect forwarding Why does C++11 have a make_shared template, but
The script works perfect in FF and IE, but not in Chrome. Could someone
I'm thinking about a problem which has some similarity with perfect forwarding, but where

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.