KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why does the following code prints "0" as the output? #include <functional> #include <iostream> int main() { typedef void (*fp_t)(); fp_t fp = nullptr; std::function<void()> f = fp; std::cout << (f == nullptr) << '\n'; } I've tested it both with gcc 4.7.2 and MSVC-11.0. I think that it's should print "1" because of the following quote from the standard: ISO/IEC 14882:2011 20.8.11.2.1 function construct/copy/destroy [func.wrap.func.con] template<class F> function(F f); template<class F, class A> function(allocator_arg_t, const A& a, F f); ... 8 Postconditions: !*this if any of the following hold: — f is a NULL function pointer. — f is a NULL pointer to member. — F is an instance of the function class template, and !f
Tags (comma-separated)
Save Edits
Cancel