Commit 8a82e909 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

thunk::fail

Reviewed By: iahs

Differential Revision: D27036059

fbshipit-source-id: 15166a6e7ec58d873a1d6799a3b1eb1ad64de420
parent cc95898a
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#pragma once #pragma once
#include <exception>
namespace folly { namespace folly {
namespace detail { namespace detail {
...@@ -27,6 +29,7 @@ namespace detail { ...@@ -27,6 +29,7 @@ namespace detail {
// * ctor: in-place constructor with given arguments // * ctor: in-place constructor with given arguments
// * dtor: in-place destructor // * dtor: in-place destructor
// * noop: no-op function with the given arguments // * noop: no-op function with the given arguments
// * fail: terminating function with the given return and arguments
struct thunk { struct thunk {
template <typename T, typename... A> template <typename T, typename... A>
static void* make(A... a) { static void* make(A... a) {
...@@ -46,8 +49,13 @@ struct thunk { ...@@ -46,8 +49,13 @@ struct thunk {
static_cast<T*>(ptr)->~T(); static_cast<T*>(ptr)->~T();
} }
template <typename... T> template <typename... A>
static void noop(T...) noexcept {} static void noop(A...) noexcept {}
template <typename R, typename... A>
static R fail(A...) noexcept {
std::terminate();
}
}; };
} // namespace detail } // namespace detail
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment