|
|
Home » Community » Newbie corner » [Solved]Vector<Vector<int>> problem
[Solved]Vector<Vector<int>> problem [message #53045] |
Mon, 17 February 2020 05:21 ![Go to next message Go to next message](theme/default/images/down.png) |
bozero
Messages: 20 Registered: June 2018
|
Promising Member |
|
|
Hi, everyone:
Please advise me how to fix the below problem.
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Vector<int> vi1,vi2;
Vector<Vector<int>> vvi;
vi1<<1<<2;
vi2<<3<<4;
vvi<<vi1<<vi2;
DUMP(vvi); // vvi = [[1, 2], [3, 4]]
}
and got error message:
...upp/uppsrc/Core/Vcont.h:104:7: note: 'constexpr Upp::Vector<int>::Vector(const Upp::Vector<int>&)'
is implicitly declared as deleted because 'Upp::Vector<int>' declares a move constructor or move assignment operator
class Vector : public MoveableAndDeepCopyOption< Vector<T> > {
^~~~~~
Test: 1 file(s) built in (0:02.91), 2918 msecs / file, duration = 2918 msecs
There were errors. (0:03.34)
The code is working on upp-mingw-11873,
but not work on upp-mingw-13664 & upp-mingw-13916.
under windows 10.
I am sorry for my stupid question and poor english.
Thank you very much
[Updated on: Wed, 19 February 2020 03:50] Report message to a moderator
|
|
|
|
Re: Vector<Vector<int>> problem [message #53062 is a reply to message #53045] |
Tue, 18 February 2020 18:43 ![Go to previous message Go to previous message](theme/default/images/up.png) ![Go to next message Go to next message](theme/default/images/down.png) |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
bozero wrote on Sun, 16 February 2020 23:21
The code is working on upp-mingw-11873,
This code is not supposed to compile with any compiler and latest version of Upp.
There are two issues with this code.
1. You are supposed to tell explicitly what you want to do with your Vector.
vvi.Add(clone(vi1));
vvi.Add(pick(vi2));
In the first case you are making a copy, in second - moving.
2. There is a problem with Vector& operator<<(const T& x)
It is supposed to look like below. This version of operator<< is missing.
Vector& operator<<(T&& x) { Add(pick(x)); return *this; }
In this case you would be able to write
vvi << pick(vi1) << pick(vi2);
Hope this helps.
Regards,
Novo
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 29 03:36:31 CEST 2024
Total time taken to generate the page: 0.02214 seconds
|
|
|