public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55038] New: c++11: operator +=
@ 2012-10-23 17:02 lisp2d at lisp2d dot net
2012-10-23 17:15 ` [Bug c++/55038] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: lisp2d at lisp2d dot net @ 2012-10-23 17:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55038
Bug #: 55038
Summary: c++11: operator +=
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: lisp2d@lisp2d.net
I transfer code to c++(2011) version and hear: the main goal is to advance
using an rvalue.
But standard say that operators +=,++,-=,-- must have an lvalue from the left
side.
Who are writes the standard?
And why I must to write cover class?
And I want to hear an advice.
code:
#include <iostream>
#include <complex>
namespace test{
class Int{
public:
signed int i;
Int()noexcept:i(){}
constexpr Int(Int const & x)noexcept:i{x.i}{}
constexpr explicit Int(signed int const & x)noexcept:i{x}{}
Int & operator =(Int const & x)noexcept{i = (x.i);return * this;}
void Swap(Int & x){std::swap(i,x.i);}
Int operator +(Int const & x){return Int{i + (x.i)};}
Int & operator +=(Int const & x){i += (x.i);return * this;}
};
int main(int,char * *){
Int x{1};
Int y{2};
Int z{3};
std::cout << "(" << x.i << "+" << y.i << ")+=" << z.i << " = " << ((x
+ y) += z).i << std::endl;
std::complex<int> cx{1};
std::complex<int> cy{2};
std::complex<int> cz{3};
std::cout << "(" << cx << "+" << cy << ")+=" << cz << " = " << ((cx +
cy) += cz) << std::endl;
int ix{1};
int iy{2};
int iz{3};
//std::cout << "(" << ix << "+" << iy << ")+=" << iz << " = " << ((ix
+ iy) += iz) << std::endl;
}
} // namespace test
int main(int n,char * * a){
return test::main(n,a);}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/55038] c++11: operator +=
2012-10-23 17:02 [Bug c++/55038] New: c++11: operator += lisp2d at lisp2d dot net
@ 2012-10-23 17:15 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2012-10-23 17:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55038
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-10-23 17:15:29 UTC ---
(In reply to comment #0)
> I transfer code to c++(2011) version and hear: the main goal is to advance
> using an rvalue.
> But standard say that operators +=,++,-=,-- must have an lvalue from the left
> side.
> Who are writes the standard?
> And why I must to write cover class?
> And I want to hear an advice.
GCC's Bugzilla is not for advice, please take these sort of questions to
somewhere more suitable e.g.
https://groups.google.com/a/isocpp.org/group/std-discussion
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-23 17:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-23 17:02 [Bug c++/55038] New: c++11: operator += lisp2d at lisp2d dot net
2012-10-23 17:15 ` [Bug c++/55038] " redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).