Question

I'm trying to develop a Linux/Win64 application using the Armadillo C++ library. The following code compiles in GCC-4.7, but fails to compile in Visual Studio 2013 using the Armadillo provided VS 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;
}

The error ocurs with function foo1:

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 last choice here, and the others should not apply based on type inference. GCC seems to agree, so there must be something different about how VC++ resolves these overloaded operators? Interestingly things resolve if I use the .at() method as in foo2. But .at() is overloaded in nearly the same pattern of methods, so why does that work? I run into related problems with operator= in my actual code, so I suspect there is something special about operators here. Are there any non-ugly ways to fix this issue? I'd like to use the normal operator() instead of method .at().

No correct solution

OTHER TIPS

This is related to MSVC connect bug #811334 as per the SO post Ryan linked in his comment here, and should be fixed in MSVC 2015.

(The bug is that MSVC is ignoring the explicit keyword on the constructor -- it's related to the linked SO post's code, but not quite the same, as the linked SO post and report deal with the lossage of explicit on conversion operators.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top