Я провожу несколько тестов с собственным (в качестве замены бустовой матрицы, которую я в настоящее время использую), и, как я пытался определить CTOR для класса поверх Eigen Matrix Я сталкиваюсь с проблемой с фрагментом кода, который создает много шумных предупреждений .Проблема явно возникает из-за путаницы в типе шаблона между скалярным типом и указателем на скалярном типе.
любая помощь или совет будут приветствоваться, спасибо.
Я определяю следующий класс шаблона
template<typename T>
class CVector : public Eigen::Matrix<T, Eigen::Dynamic, 1, Eigen::StorageOptions::AutoAlign>
{
public:
typedef typename Eigen::Matrix<T, Eigen::Dynamic, 1, Eigen::StorageOptions::AutoAlign> Base_Vector;
.....
Я использую кусок кода, предоставленный Eigen doc, для построения из Eigen объекта и нескольких строк ниже 3 конструкторов
CVector(size_t size1) : Base_Vector(size1)
{}
CVector(size_t size1, T val): Base_Vector(size1)
{
this->setConstant(5);
}
CVector(T* val_array, size_t val_array_size): Base_Vector(val_array_size)
{
std::copy(val_array, val_array+val_array_size, this->data());
}
Но последний CTORкак только я попытаюсь использовать его, напишу что-то вроде:
int tab [] = { 1,2,3,4,5 };
CVector<int> v3(tab, 5);
С VS'2015 я получу:
warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of data
note: see reference to class template instantiation 'Eigen::internal::is_convertible_impl<unsigned __int64,int>' being compiled
note: see reference to class template instantiation 'Eigen::internal::is_convertible<std::T,int>' being compiled
with
[
T=std::size_t
]
note: see reference to function template instantiation 'Eigen::Matrix<int,-1,1,0,-1,1>::Matrix<std::size_t>(const T &)' being compiled
with
[
T=std::size_t
]
note: see reference to function template instantiation 'Eigen::Matrix<int,-1,1,0,-1,1>::Matrix<std::size_t>(const T &)' being compiled
with
[
T=std::size_t
]
note: while compiling class template member function 'CVector<int>::CVector(T *,std::size_t)'
with
[
T=int
]
note: see reference to function template instantiation 'CVector<int>::CVector(T *,std::size_t)' being compiled
with
[
T=int
]
note: see reference to class template instantiation 'CVector<int>' being compiled
Но с другой стороны, нетпредупреждение вообще, когда я использую
float tab [] = { 1,2,3,4,5 };
CVector<float> v3(tab, 5);