Are function-local typedefs visible inside C++0x lambdas?

后端 未结 4 964
既然无缘
既然无缘 2021-01-11 13:27

I\'ve run into a strange problem. The following simplified code reproduces the problem in MSVC 2010:

template 
struct dummy
{
    static T f         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-11 14:10

    This is not really an answer to your question, but just exploring the problem further. I was wondering if the compiler has issues dealing with types declared in an enclosing scope, so tried this out:

    #include 
    
    template 
    void do_test(Func pFunc) {
    }
    
    template 
    void test_trait(void) {
       class Something { public: int foo; };
    
       do_test ([] (T pX) {
          Something A; A.foo = 12;
       });
    }
    
    int main(void) {
        test_trait ();
    }
    

    Here, I'm just trying to create a local type in the enclosing scope and use it from within the lambda function. Not only does this not compile (with Visual Studio 2010, Beta 2) but it actually crashes the compiler with a C1001 internal error.

提交回复
热议问题