alexfh added a comment.

In http://reviews.llvm.org/D15411#307274, @aaron.ballman wrote:

> In http://reviews.llvm.org/D15411#307030, @alexfh wrote:
>
> > BTW, Richard, is the possibility of assignment of an integer to a 
> > std::string a bug in the standard?
>
>
> This is the result of:
>
>   basic_string& operator=(charT c);
>   Returns: *this = basic_string(1,c).
>
>
> So I believe it is by design.


I see how the current behavior can be explained by the standard, however I'm 
not sure this was the intention of the standard to specifically allow this 
behavior.

And if it's unintended (and I'd say undesired), the standard could also be 
changed to enforce a mechanism to disallow assignment of std::string from other 
integer types (e.g. a templated deleted operator= enable_if'd for all integral 
types except for charT, or something like that).

Maybe it wouldn't be reasonable for some reason, but it's worth trying ;)


http://reviews.llvm.org/D15411



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to