dpj*_*dpj 6 c++ c++11 std-function
这里:
http://en.cppreference.com/w/cpp/utility/functional/function
operator bool 描述:"检查存储的可调用对象是否有效".
据推测,默认构造std::function无效,但这是唯一的情况吗?
另外,它如何检查它是否有效?
是否恰好operator()引发std::bad_function_call了对象无效的情况?
它写得很糟糕,你的困惑是合理的."有效"意味着"有目标".
一个std::function"有目标",当它被赋予的功能:
std::function<void()> x; // no target
std::function<void()> y = some_void_function; // has target
x = some_other_void_function; // has target
y = nullptr; // no target
x = y; // no target
Run Code Online (Sandbox Code Playgroud)
他们应该在使用之前定义"有效",或者只是坚持使用官方措辞.
| 归档时间: |
|
| 查看次数: |
1501 次 |
| 最近记录: |