In some case, I have to std::function delete-itself during std::function call :
    std::function<void (void)> test;
    std::shared_ptr<int> tt = std::make_shared<int>(10);
    test = [=,&test]() 
    {
        std::cout << tt.use_count() << std::endl;
        test = nullptr; // destroy self
        return;
    };
    std::cout << tt.use_count() << std::endl;
    tt = nullptr;
    test();
is it will be a problem ? Because it destroy it-self during its call.It's OK for vs2015 and xcode. Or I should write like this :
test = [=,&test]() 
    {
        std::shared_ptr<void> raii(nullptr,[&](){ test = nullptr;  }); // destroy itself
        std::cout << tt.use_count() << std::endl;
        return;
    };
 
     
    