Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Re: Shouldn't Assignable concepts stop supporting assignment-to-rvalue?

From: Sebastian Gesemann (s.gesemann_at_[hidden])
Date: 2009-01-06 18:04:17


On Tue, Jan 6, 2009 at 7:59 PM, Niels Dekker <nielsprogramming_at_[hidden]> wrote:
> Note: this question of mine isn't specifically meant to be a ConceptGCC
> feature request. I'm just interested to hear your opinion. Especially
> because I'm working on a resolution of a library issue, proposing to
> disallow assignment to an rvalue for most of the Standard Library types:
> "Ref-qualifiers for assignment operators",
> http://home.roadrunner.com/~hinnant/issue_review/lwg-active.html#941

I don't think that mistyping is a big issue. Adding ref qualifiers in
the STL would take functionality away. So, it's not backwards
compatible, strictly speaking. I don't know whether this would really
affect any code base, though. Anyhow, I'd like to see the ref
qualifier in HasAssign<>:

   auto concept HasAssign<typename T, typename U>
     typename result_type;
     result_type T::operator=(U) &; // <-- added ref qualifier (not in draft)
   }

which would make the compiler reject your restricted function template
"assign_to_rvalue". The original version of this (N2800.pdf) obviously
requires rvalues to be assignable as well which renders built-in types
non-assignable as far as this concept is concerned.

Cheers!
SG