So basically here is the simplified version of my code that doesn't compile:
class MyClass
{
static void foo(X)
{
//do something
}
static void foo(Y)
{
//do something
}
static void bar()
{
std::for_each(collection->begin(), collection->end(),
[&](X& elem)
{
foo(elem); //this call generates the error
});
}
};
Compiler: MSVC 2010 with SP1 installed The error message it generates is: error C3861: 'foo': identifier not found
The error doesn't occur if I rename either foo() function, or if I call it outside the lambda.
I managed to solve this by explicitly qualifying foo(). The interesting part is that ::MyClass::foo(elem) works but MyClass::foo(elem) does not.
Try to explicitly qualify foo:
MyClass::foo(elem);
(which might be a required work-around for a MSVC10 bug, GCC accepts your code without qualification)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With