diff --git a/include/pybind11/detail/inference.h b/include/pybind11/detail/inference.h new file mode 100644 index 0000000000..aceb5f2f61 --- /dev/null +++ b/include/pybind11/detail/inference.h @@ -0,0 +1,141 @@ +/* + pybind11/detail/inference.h -- Simple inference for generic functions + + Copyright (c) 2018 Eric Cousineau + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "common.h" + +NAMESPACE_BEGIN(PYBIND11_NAMESPACE) +NAMESPACE_BEGIN(detail) + +// SFINAE for functors. +// N.B. This *only* distinguished between function / method pointers and +// lambda objects. It does *not* distinguish among other types. +template +using enable_if_lambda_t = enable_if_t>::value, T>; + +template +struct type_at_impl { + using type = typename type_at_impl::type; +}; + +template +struct type_at_impl { + using type = T; +}; + +// Convenient mechanism for passing sets of arguments. +template +struct type_pack { + static constexpr int size = sizeof...(Ts); + + template