|
|
Home » U++ Library support » U++ Core » C++11: Vector is missing copy contructor/assignment operator (Compiling for C++11 with gcc 4.8 or newer fails)
C++11: Vector is missing copy contructor/assignment operator [message #43173] |
Wed, 28 May 2014 10:24 |
|
Hi,
OS: Ubuntu 14.04
uppsrc revision 7400
gcc version 4.8.2
It seems that from gcc-4.8, the Vector class gives a compiler error when building with the -std=c++0x flag.
According to C++11 specs, it is a valid error, since it should not implicitly make copy constructors for moveable objects.
Example:
CONSOLE_APP_MAIN
{
Vector<int> v;
Vector<int> r = v;
VectorMap<int,String> vm;
VectorMap<int,String> rvm = vm;
Vector<String> rv = vm.GetValues();
}
Compiler gives these errors:
/home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp: In function 'void ConsoleMainFn_()':
/home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:10:18: error: use of deleted function 'constexpr Upp::Vector<int>::Vector(const Upp::Vector<int>&)'
Vector<int> r = v;
^
In file included from /home/steffen/Projects/upp/uppsrc/Core/Core.h:282:0,
from /home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:1:
/home/steffen/Projects/upp/uppsrc/Core/Vcont.h:13: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> > {
^
/home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:13:30: error: use of deleted function 'Upp::VectorMap<int, Upp::String>::VectorMap(const Upp::VectorMap<int, Upp::String>&)'
VectorMap<int,String> rvm = vm;
^
In file included from /home/steffen/Projects/upp/uppsrc/Core/Core.h:285:0,
from /home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:1:
/home/steffen/Projects/upp/uppsrc/Core/Map.h:145:7: note: 'Upp::VectorMap<int, Upp::String>::VectorMap(const Upp::VectorMap<int, Upp::String>&)' is implicitly deleted because the default definition would be ill-formed:
class VectorMap : public MoveableAndDeepCopyOption<VectorMap<K, T, HashFn> >,
^
/home/steffen/Projects/upp/uppsrc/Core/Map.h:145:7: error: use of deleted function 'Upp::AMap<int, Upp::String, Upp::Vector<Upp::String>, Upp::StdHash<int> >::AMap(const Upp::AMap<int, Upp::String, Upp::Vector<Upp::String>, Upp::StdHash<int> >&)'
/home/steffen/Projects/upp/uppsrc/Core/Map.h:2:7: note: 'Upp::AMap<int, Upp::String, Upp::Vector<Upp::String>, Upp::StdHash<int> >::AMap(const Upp::AMap<int, Upp::String, Upp::Vector<Upp::String>, Upp::StdHash<int> >&)' is implicitly deleted because the default definition would be ill-formed:
class AMap {
^
/home/steffen/Projects/upp/uppsrc/Core/Map.h:2:7: error: use of deleted function 'Upp::Index<int>::Index(const Upp::Index<int>&)'
In file included from /home/steffen/Projects/upp/uppsrc/Core/Core.h:284:0,
from /home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:1:
/home/steffen/Projects/upp/uppsrc/Core/Index.h:210:7: note: 'Upp::Index<int>::Index(const Upp::Index<int>&)' is implicitly declared as deleted because 'Upp::Index<int>' declares a move constructor or move assignment operator
class Index : MoveableAndDeepCopyOption< Index<T, HashFn > >,
^
In file included from /home/steffen/Projects/upp/uppsrc/Core/Core.h:285:0,
from /home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:1:
/home/steffen/Projects/upp/uppsrc/Core/Map.h:2:7: error: use of deleted function 'constexpr Upp::Vector<Upp::String>::Vector(const Upp::Vector<Upp::String>&)'
class AMap {
^
In file included from /home/steffen/Projects/upp/uppsrc/Core/Core.h:282:0,
from /home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:1:
/home/steffen/Projects/upp/uppsrc/Core/Vcont.h:13:7: note: 'constexpr Upp::Vector<Upp::String>::Vector(const Upp::Vector<Upp::String>&)' is implicitly declared as deleted because 'Upp::Vector<Upp::String>' declares a move constructor or move assignment operator
class Vector : public MoveableAndDeepCopyOption< Vector<T> > {
^
/home/steffen/Projects/Ultimatepp/VectorTest/VectorTest.cpp:14:35: error: use of deleted function 'constexpr Upp::Vector<Upp::String>::Vector(const Upp::Vector<Upp::String>&)'
Vector<String> rv = vm.GetValues();
|
|
|
|
|
Re: C++11: Vector is missing copy contructor/assignment operator [message #43191 is a reply to message #43176] |
Mon, 02 June 2014 15:56 |
|
Thank you very much, Mirek.
I totally missed that announcement.
For some time I had the error in a single place, but when I got it on an array too I tried to make the tests above.
And it was a bit hard for me to figure out which constructor or operator was in use in the different places.
It took only 5 seconds to fix my two error though.
|
|
|
Goto Forum:
Current Time: Mon May 06 05:59:05 CEST 2024
Total time taken to generate the page: 0.03395 seconds
|
|
|