"The character cannot be defined inside" unrelated_namespace "" - lambda nested in lambda-pass-as-argument

The following code will compile with FIXME installed, but not without it. The corresponding compiler is visual studio 2013.

#include <functional>

#ifdef FIXME
namespace unrelated_namespace {
    struct ned {};
}
#endif

namespace something {
    struct do_something {
        template <typename T>
        do_something(T f) {}
    };
}

using namespace something;

do_something my_something([](){
    std::function<void(void)> inner([]{});
});

#ifndef FIXME
namespace unrelated_namespace {
    struct ned {};
}
#endif

      

The errors are as follows:

Error   2   error C2888: '<lambda_22ffa30be171afdd76e6bc1bf85e9dd7>::()::<lambda_cac50c1ea5c52e062ca61c564ead686c>' :
  symbol cannot be defined within namespace 'unrelated_namespace'
  C:\hudson\workspace\phtest_build_windows\replication_dev\kernel\foe\test\serialize_unit.cpp   20  1   foe

Error   3   error C2888: '<lambda_22ffa30be171afdd76e6bc1bf85e9dd7>::<helper_func_cdecl>::<lambda_8c92b136dc3e83c8e0db25c06e4203d5>' : 
  symbol cannot be defined within namespace 'unrelated_namespace'   
  C:\hudson\workspace\phtest_build_windows\replication_dev\kernel\foe\test\serialize_unit.cpp   20  1   foe

Error   3   error C2888: '<lambda_22ffa30be171afdd76e6bc1bf85e9dd7>::<helper_func_cdecl>::<lambda_8c92b136dc3e83c8e0db25c06e4203d5>' :
  symbol cannot be defined within namespace 'unrelated_namespace'   
  C:\hudson\workspace\phtest_build_windows\replication_dev\kernel\foe\test\serialize_unit.cpp   20  1   foe

      

g ++ uses code without complaint (e.g. http://ideone.com/ZEPYE7 ).

Is there any explanation for this behavior other than a compiler error?

+3
c ++ lambda namespaces c ++ 11 visual-studio-2013


source to share


No one has answered this question yet

Check out similar questions:

331
How do I pass a unique_ptr argument to a constructor or function?
296
How do I define a method that takes a lambda as a parameter in Java 8?
268
error: passing xxx as argument 'this' of argument xxx discards qualifiers
171
Passing lambda capture as a function pointer
sixteen
Passing lambda expression to lambda argument c ++ 11
fourteen
Difference between capturing and passing an argument in lambda functions
fourteen
I cant pass lambda as std :: function
4
C ++ lambda as static member in CRTP class does not compile in Visual Studio 15
0
communication error with non-member functions
0
#ifdef [true state] # endif block. Commenting out line changes #ifdef & #endif compile?



All Articles
Loading...
X
Show
Funny
Dev
Pics