P
Pepijn Kenter
Dear experts.
I have a vector<float> and want to convert that to a vector<double>. I
optimistically tried:
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<float> vFloats;
vFloats.push_back(1.0);
vFloats.push_back(2.0);
vector<double> vDoubles = static_cast<vector<double> >( vFloats);
}
But it gave the following errors:
cast.cpp: In function `int main()':
cast.cpp:10: error: no matching function for call to `std::vector<double,
bits/stl_vector.h:220: note: candidates are: std::vector<_Tp,
_Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = double, _Alloc
= std::allocator<double>]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
bits/stl_vector.h:206: note: std::vector<_Tp,
_Alloc>::vector(size_t) [with _Tp = double, _Alloc =
std::allocator<double>]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
bits/stl_vector.h:193: note: std::vector<_Tp,
_Alloc>::vector(size_t, const _Tp&, const typename std::_Vector_base<_Tp,
_Alloc>::allocator_type&) [with _Tp = double, _Alloc =
std::allocator<double>]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
bits/stl_vector.h:182: note: std::vector<_Tp,
_Alloc>::vector(const typename std::_Vector_base<_Tp,
_Alloc>::allocator_type&) [with _Tp = double, _Alloc =
std::allocator<double>]
I can only derive from them that there is no casting method available. It
mentions some candidates but I wouldn't know how to use them.
Is there some simple way to cast the vector or do I just have to write my
own conversion routine?
Regards, Pepijn Kenter.
I have a vector<float> and want to convert that to a vector<double>. I
optimistically tried:
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<float> vFloats;
vFloats.push_back(1.0);
vFloats.push_back(2.0);
vector<double> vDoubles = static_cast<vector<double> >( vFloats);
}
But it gave the following errors:
cast.cpp: In function `int main()':
cast.cpp:10: error: no matching function for call to `std::vector<double,
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0std::allocator said:
bits/stl_vector.h:220: note: candidates are: std::vector<_Tp,
_Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = double, _Alloc
= std::allocator<double>]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
bits/stl_vector.h:206: note: std::vector<_Tp,
_Alloc>::vector(size_t) [with _Tp = double, _Alloc =
std::allocator<double>]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
bits/stl_vector.h:193: note: std::vector<_Tp,
_Alloc>::vector(size_t, const _Tp&, const typename std::_Vector_base<_Tp,
_Alloc>::allocator_type&) [with _Tp = double, _Alloc =
std::allocator<double>]
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
bits/stl_vector.h:182: note: std::vector<_Tp,
_Alloc>::vector(const typename std::_Vector_base<_Tp,
_Alloc>::allocator_type&) [with _Tp = double, _Alloc =
std::allocator<double>]
I can only derive from them that there is no casting method available. It
mentions some candidates but I wouldn't know how to use them.
Is there some simple way to cast the vector or do I just have to write my
own conversion routine?
Regards, Pepijn Kenter.