static_function_deleter.
authorYedidya Feldblum <yfeldblum@fb.com>
Fri, 21 Aug 2015 22:24:06 +0000 (15:24 -0700)
committerfacebook-github-bot-9 <folly-bot@fb.com>
Fri, 21 Aug 2015 23:20:21 +0000 (16:20 -0700)
commit74a1c03549d4ae3374eba514b6bcb564e7779929
tree6bdb4046b66a34863b743b6282d79cf74dd3af39
parent671368bef6addc3706740e347e90a7b6f353e2d6
static_function_deleter.

Summary: [Folly] static_function_deleter.

So you can write this:

    using BIO_deleter = folly::static_function_deleter<BIO, &BIO_free>;
    auto buf = std::unique_ptr<BIO, BIO_deleter>(BIO_new(BIO_s_mem()));
    buf = nullptr;

In place of this:

    struct BIO_deleter {
      void operator()(BIO* bio) {
        BIO_free(bio);
      }
    };
    auto buf = std::unique_ptr<BIO, BIO_deleter>(BIO_new(BIO_s_mem()));
    buf = nullptr;

Reviewed By: @alandau

Differential Revision: D2364544
folly/Memory.h
folly/test/MemoryTest.cpp