function_view: Allow empty function views

Change-Id: I80244114f69f34940c7b0f6e2092c3706f91ae76
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/stdplus/function_view.hpp b/include/stdplus/function_view.hpp
index ea9e6e7..dc8287c 100644
--- a/include/stdplus/function_view.hpp
+++ b/include/stdplus/function_view.hpp
@@ -62,6 +62,9 @@
     static_assert(sizeof(fun) == sizeof(memfun));
     void* obj;
 
+    inline function_view_base() : fun(nullptr), obj(nullptr){};
+    inline function_view_base(std::nullptr_t) : function_view_base(){};
+
     template <bool Nx2>
     constexpr function_view_base(R (*f)(Args...) noexcept(Nx2)) noexcept :
         fun(f), obj(nullptr)
@@ -99,6 +102,11 @@
         }
         return memfun(obj, std::forward<Args>(args)...);
     }
+
+    inline explicit operator bool() const noexcept
+    {
+        return fun != nullptr;
+    }
 };
 
 } // namespace detail
diff --git a/test/function_view.cpp b/test/function_view.cpp
index ff95f46..7db236d 100644
--- a/test/function_view.cpp
+++ b/test/function_view.cpp
@@ -46,6 +46,7 @@
 TEST(FunctionView, Ptr)
 {
     function_view<int(int, int)> fv = add;
+    EXPECT_TRUE(fv);
     EXPECT_EQ(3, fv(1, 2));
     EXPECT_EQ(14, fv(5, 9));
     fv = mul;
@@ -54,6 +55,9 @@
     function_view fv2 = add;
     EXPECT_EQ(1, fv2(1, 0));
 
+    fv = nullptr;
+    EXPECT_FALSE(fv);
+
     EXPECT_EQ(8, callFv(add));
 }