+namespace {
+class disposable {
+ public:
+ explicit disposable(std::function<void()> onDispose) :
+ onDispose_(std::move(onDispose)) {}
+ static void dispose(disposable* f) {
+ ASSERT_NE(nullptr, f);
+ f->onDispose_();
+ delete f;
+ }
+ private:
+ std::function<void()> onDispose_;
+};
+}
+
+TEST(static_function_deleter, example) {
+ size_t count = 0;
+ using disposable_deleter =
+ static_function_deleter<disposable, &disposable::dispose>;
+ make_unique<disposable, disposable_deleter>([&] { ++count; });
+ EXPECT_EQ(1, count);
+}
+
+TEST(static_function_deleter, nullptr) {
+ using disposable_deleter =
+ static_function_deleter<disposable, &disposable::dispose>;
+ std::unique_ptr<disposable, disposable_deleter>(nullptr);
+}
+