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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:44:00+00:00 2026-06-12T07:44:00+00:00

Assume I have some templated class template <typename T> struct Dummy { // …

  • 0

Assume I have some templated class

template <typename T>
struct Dummy {
    // ...
};

And I want to overload a function ‘foo’ such that it accepts a lvalue
or rvalue reference of it. I can do this using some IsDummy trait
as follows:

template <typename A>
std::enable_if<IsDummy<A>::value, void>
foo(A &&dummy)
{
    // ....
}

IIRC in some C++11 draft it was legal that

template <typename A>
foo(Dummy<A> &&dummy)
{
    // ....
}

would accept both, lvalue- and value- references.

Now my questions:

  • a) Is it correct that it was allowed in some draft?

  • b) Why was this feature/bug removed? I think I read somewhere that it was due to a conflict with “concepts”.

However, I can’t find appropriate references for this any more. Does somebody have a better memory or bookmarks?

  • 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-12T07:44:02+00:00Added an answer on June 12, 2026 at 7:44 am

    a) Is it correct that it was allowed in some draft?

    Yes, it was allowed in what is known as “rvalue references 1.0” (see N2118).

    b) Why was this feature/bug removed? I think I read somewhere that it was due to a conflict with “concepts”.

    It was removed because binding an rvalue reference to an lvalue could lead to a violation of the “Principle of Type-safe Overloading” in the presence of Concepts:

    Every function must be type-safe in isolation, without regard to how it has been overloaded.

    For example, if we define the following overloads:

    template< CopyConstructible T > void f( T const & t ); // #1
    template< MoveConstructible T > void f( T && t );      // #2
    

    Then calling f with a copyable lvalue would select #1. However, if T is a non-copyable type (e.g. std::unique_ptr) then #1 is not a viable overload so the compiler must select #2, possibly stealing resources from an lvalue without warning.

    See “rvalue references 2.0” (N2844) for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have a function like this: static const boost::int32_t SOME_CONST_VALUE = 1073741823; template<typename
Assume I have the following exemplary function: template <typename Fn> auto call(Fn fn) ->
Assume you have a function read_key and normally it does some stuff. You someone
Assume some domain and view objects (that have no common base class) public class
I have a templated class which looks as follows (assume a using namespace std
I have this... template <typename Key, typename Value> class A { public: //... private:
We have some code that looks like this: class Serializer { public: template<class Type>
Hi assume that I have class A : using namespace std; template <class T>
Basically, I have a templated class that runs some algorithm, and that algorithm needs
Let's assume, I have some sequence, e.g. Fibonacci numbers, defined as a template: template

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.