Reputation: 7459
I'm trying to hold polynomial coefficients in QVector
. My polynomials are of degree 2, so it has three numbers.
When I define QVector<double[3]> zeros_Real(n + 1)
I get an error (below). First, I thought I could use QVector<QVector<double>>
but it will be speed and memory problem, so I decided to not do that.
Why can't I have a QVector
of double[3]
elements?
The error:
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make: *** [debug] Error 2
21:27:01: The process "C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project untitled11 (kit: Desktop Qt 5.5.1 MinGW 32bit)
When executing step "Make"
Upvotes: 0
Views: 1538
Reputation: 19607
QVector
(like std::vector
) requires its elements to be copyable (it has to copy the elements during reallocation). Arrays can not be copied, that implies you can't have QVector<double[3]>
.
The working alternative is to use std::array
(C++11 or later):
QVector<std::array<double, 3>>
Which can be copied. Qt doesn't have its own QArray
, so you have to mix the standard library and Qt containers like this.
Upvotes: 5