C ++ Armadillo: GCC vs VC ++ 2013: Operator () and overload

I am trying to develop a Linux / Win64 application using the Armadillo C ++ library. The following code compiles in GCC-4.7, but does not compile in Visual Studio 2013 using the Armadillo project project file.

#include <iostream> #include "armadillo" using namespace arma; using namespace std; //works in GCC-4.7 //VC++2013: compile error: C3066 void foo1(vec::fixed<4> &bar) { bar(1) = 1.; } //works void foo2(vec::fixed<4> &bar) { bar.at(2) = 1.; } //works void foo3(vec &bar) { bar(3) = 1.; } int main(int argc, char** argv) { cout << "Armadillo version: " << arma_version::as_string() << endl; vec::fixed<4> bar; bar.zeros(); foo1(bar); foo2(bar); foo3(bar); cout << "Bar: " << bar << endl; return 0; } 

Ocurs error with foo1 function:

 1>example1.cpp(11): error C3066: there are multiple ways that an object of this type can be called with these arguments 1> ../armadillo_bits/Col_bones.hpp(186): could be 'const arma::subview_col<eT> arma::Col<eT>::operator ()(const arma::span &) const' 1> with 1> [ 1> eT=double 1> ] 1> ../armadillo_bits/Col_bones.hpp(186): or 'arma::subview_col<eT> arma::Col<eT>::operator ()(const arma::span &)' 1> with 1> [ 1> eT=double 1> ] 1> ../armadillo_bits/Col_bones.hpp(186): or 'double &arma::Mat<double>::operator ()(const arma::uword)' 1> ../armadillo_bits/Col_bones.hpp(186): or 'const double &arma::Mat<double>::operator ()(const arma::uword) const' 1> ../armadillo_bits/Col_bones.hpp(205): or 'double &arma::Col<double>::fixed<4>::operator ()(const arma::uword)' 1> ../armadillo_bits/Col_bones.hpp(206): or 'const double &arma::Col<double>::fixed<4>::operator ()(const arma::uword) const' 1> while trying to match the argument list '(int)' 

Obviously, I want the second to be the last choice here, and the rest should not be applied based on type inference. GCC seems to agree, so there must be something else in how VC ++ resolves these overloaded operators? Interestingly, everything is solved if I use the .at() method, as in foo2. But .at() overloaded by almost the same method scheme, so why does this work? I am facing related issues with the = operator in my actual code, so I suspect there is something special here. Are there any non ugly ways to fix this problem? I would like to use regular operator() instead of the .at() method.

+6
source share
1 answer

This is due to a connection error with MSVC # 811334 according to SO post Ryan is linked in his comment here and should be fixed in MSVC 2015.

(The error is that MSVC ignores the explicit keyword on the constructor - it is associated with the associated SO code, but not exactly the same as the associated SO mail and report handling the loss of explicit to conversion statements.)

0
source

All Articles