73fc2dcb   
   From: dave@boostpro.com   
      
   on Thu Apr 05 2012, Gene Bushuyev wrote:   
      
   > On Apr 4, 10:21 am, "Alf P. Steinbach" +use...@gmail.com> wrote:   
   >> However, I would suggest the in my view simpler and more direct   
   >>   
   >> template< class Type >   
   >> void f( Type&& that)   
   >> {   
   >> A b(std::move(that));   
   >> }   
   >>   
   >> template< class Type >   
   >> void f( Type& that ); // No way (lvalue => ambiguous).   
   >>   
   >> which simply catches any lvalue actual argument with the second   
   >> signature, which (in that case) produces an ambiguity error, and just   
   >> for good measure is left unimplemented.   
   >   
   > You can be even more direct about it and make function deleted:   
   >   
   > template< class Type > void f( Type& that ) = delete;   
   >   
   > Though I must say, the original issue sounds too contrived, and the   
   > example demonstrates incorrect use, not the language problem. When the   
   > perfect forwarding syntax is used it's always the intention to   
   > forward   
      
   I'm not entirely sure of that. For the same reason we made it that   
   rvalue references only bind to rvalues, you could get into a situation   
   like this:   
      
      
    template    
    typename some_trait::type f(A const& x)   
    {   
    return g(x);   
    }   
      
    template    
    typename other_trait::type f(A&& x)   
    {   
    return g(std::move(x));   
    }   
      
   if the first overload gets eliminated due to SFINAE, we have a similar   
   problem.   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|