Commit 55dfcb03 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

let some thunk members take variadic args

Summary: In particular, let `make` and `ctor` take variadic arguments since there is no cost.

Reviewed By: iahs

Differential Revision: D27024839

fbshipit-source-id: 805c65fdc79f60af1256a4c36be94bb22c163bdd
parent 6329dbd5
......@@ -420,27 +420,27 @@ namespace detail {
// thunk
//
// A carefully curated collection of generic general-purpose thunk templates:
// * make: operator new with default constructor
// * make: operator new with given arguments
// * ruin: operator delete
// * ctor: in-place default constructor
// * ctor: in-place constructor with given arguments
// * dtor: in-place destructor
// * noop: no-op function with the given arguments
struct thunk {
template <typename T>
static void* make() {
return new T();
template <typename T, typename... A>
static void* make(A... a) {
return new T(static_cast<A>(a)...);
}
template <typename T>
static void ruin(void* ptr) noexcept {
static void ruin(void* const ptr) noexcept {
delete static_cast<T*>(ptr);
}
template <typename T>
static void ctor(void* ptr) {
::new (ptr) T();
template <typename T, typename... A>
static void ctor(void* const ptr, A... a) {
::new (ptr) T(static_cast<A>(a)...);
}
template <typename T>
static void dtor(void* ptr) noexcept {
static void dtor(void* const ptr) noexcept {
static_cast<T*>(ptr)->~T();
}
......
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