Visual Studio 2013 C++ - Passing std::unique_ptr to a bound function

前端 未结 3 1766
走了就别回头了
走了就别回头了 2020-12-21 03:53

Using Visual Studio 2013 RC and C++, I\'m trying to pass an std::unique_ptr to a function that has been bound using std::bind. However, I\'m having

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 04:17

    You have to move the parameter into the bound call to func also. Not only in the invocation of bound

    bound(std::move(ptr));
    

    but also in the binding:

    std::function)> bound =
        std::bind(func,
                  std::bind(std::move&>,
                            std::placeholders::_1));
    

    This is compiling in VS2013 (update 4) for me.

提交回复
热议问题