// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. // This source code is licensed under both the GPLv2 (found in the // COPYING file in the root directory) and Apache 2.0 License // (found in the LICENSE.Apache file in the root directory). #pragma once #include #include #include #include "rocksdb/rocksdb_namespace.h" namespace ROCKSDB_NAMESPACE { namespace detail { template struct IndexSequence {}; template struct IndexSequenceHelper : public IndexSequenceHelper {}; template struct IndexSequenceHelper<0U, Next...> { using type = IndexSequence; }; template using make_index_sequence = typename IndexSequenceHelper::type; template void call(Function f, Tuple t, IndexSequence) { f(std::get(t)...); } template void call(Function f, Tuple t) { static constexpr auto size = std::tuple_size::value; call(f, t, make_index_sequence{}); } } // namespace detail template class FunctorWrapper { public: explicit FunctorWrapper(std::function functor, Args &&...args) : functor_(std::move(functor)), args_(std::forward(args)...) {} void invoke() { detail::call(functor_, args_); } private: std::function functor_; std::tuple args_; }; } // namespace ROCKSDB_NAMESPACE