Topic: concept RvalueReference


Author: Douglas Gregor <doug.gregor@gmail.com>
Date: Thu, 19 Feb 2009 11:19:32 CST
Raw View
On Feb 13, 3:09 pm, SG <s.gesem...@gmail.com> wrote:
> Hi!
>
> I found in N2831 (by D. Gregor, and D. Abrahams) the following
> concept:
>
>    concept RvalueReference<typename T> { }
>    template<typename T> concept_map RvalueReference<T&&> { }
>
> The intention is to make RvalueReference<X> satisfied if and only if X
> is an rvalue reference. But I'm not sure if that's really the correct
> way to write the tempalted concept_map because of the reference
> collapsing rules. Example:
>
>    RvalueReference<int&>
>
> Can the compiler deduce T to be "int&" so that the concept_map makes
> "int& &&" = "int&" (due to reference collapsing rules) model the
> RvalueReference concept?

No, it can't. The special rule that deduces a reference type
(12.8.2.1p3) only applies when the 'T&&' occurs as a function
parameter type. It does not apply when 'T&&' is a template argument
within a concept map template or a class template partial
specialization.

> If so, would the following work as fix:
>
>    concept RvalueReference<typename T> { }
>
>    template<typename T>
>    requires !LvalueReference<T>
>    concept_map RvalueReference<T&&> { }
>
> ?

This is well-formed but unnecessary.

   - Doug


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: SG <s.gesemann@gmail.com>
Date: Fri, 13 Feb 2009 17:09:53 CST
Raw View
Hi!

I found in N2831 (by D. Gregor, and D. Abrahams) the following
concept:

   concept RvalueReference<typename T> { }
   template<typename T> concept_map RvalueReference<T&&> { }

The intention is to make RvalueReference<X> satisfied if and only if X
is an rvalue reference. But I'm not sure if that's really the correct
way to write the tempalted concept_map because of the reference
collapsing rules. Example:

   RvalueReference<int&>

Can the compiler deduce T to be "int&" so that the concept_map makes
"int& &&" = "int&" (due to reference collapsing rules) model the
RvalueReference concept? If so, would the following work as fix:

   concept RvalueReference<typename T> { }

   template<typename T>
   requires !LvalueReference<T>
   concept_map RvalueReference<T&&> { }

?

Cheers!
SG

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]