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.
Update:
I managed to solve this by explicitly qualifying foo(). The interesting part is that ::MyClass::foo(elem) works but MyClass::foo(elem) does not.
foo? Clearly notfoo(X)andfoo(Y)[&]rather than[]?