Home » U++ Library support » U++ Core » Please help! New transfer semantic issue!
Please help! New transfer semantic issue! [message #46161] |
Mon, 21 March 2016 12:36  |
|
Maybe problem is trivial, but I stopped on it.
There is class Line
class Line {
....
Line( Point p1, Point p2 ) // constructor
}
and class Figure
class Line {
public:
Array<Line> lines;
}
and if I use compiler option -std=c++11
I get error message while adding new Line to Lines
Without option -std=c++11 all OK.
What right way to do this with -std=c++11 option?
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: Please help! New transfer semantic issue! [message #46163 is a reply to message #46161] |
Mon, 21 March 2016 13:52   |
|
sergeynikitin wrote on Mon, 21 March 2016 12:36if I use compiler option -std=c++11
I get error message while adding new Line to Lines
Hi Sergey,
What does the error message say? It is really hard to guess without seeing the entire class nor the error...
Best regards,
Honza
|
|
|
|
|
|
|
Re: Please help! New transfer semantic issue! [message #46169 is a reply to message #46168] |
Mon, 21 March 2016 16:22   |
|
Thanks for opinion.
But Next function has no parameters:
void AddMovingLine(){
lines.Add(Line(checked_elem_point+Point(0,0),checked_elem_point+Point(0,0)));
moving_line = lines.GetCount()-1;
}
But have same problem.
There are problems while creating array item.
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
|
|
Re: Please help! New transfer semantic issue! [message #46173 is a reply to message #46172] |
Tue, 22 March 2016 07:18   |
|
Yes.
class Line {
typedef Line CLASSNAME;
public:
void Paint ( Draw& w, bool moving );
Line();
Line( Point _p1, Point _p2 );
String ToString() const;
public:
Point p1, p2;
ElementPin* elp1;
ElementPin* elp2;
Array<Segment> segs;
Array<ElementPin> lines;
};
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: Please help! New transfer semantic issue! [message #46174 is a reply to message #46173] |
Tue, 22 March 2016 21:47   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Contained members Array<Segment> segs and Array<ElementPin> lines are the culprits.
Mirek would be able to give you the best suggestion. However explicitly define a copy constructor and a move constructor will fix the problem.
Something like
// public:
Line(const Line& ln):p1(ln.p1),p2(ln.p2), elp1(???),elp2(???),
segs(ln.segs,1), // make a deep copy
lines(ln.lines,1) // ditto
{}
Line(Line&& ln): p1(ln.p1),p2(ln.p2),elp1(???), elp2(???),
segs(pick(ln.segs)),
lines(pick(ln.lines))
{}
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 28 14:34:06 CEST 2025
Total time taken to generate the page: 0.03639 seconds
|