aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndre Schmeißer <schmeisser@users.noreply.github.com>2019-08-19 12:54:33 +0200
committerWenzel Jakob <wenzel.jakob@epfl.ch>2019-08-19 12:54:33 +0200
commit19189b4c2c7f205ae16fe9d0df121b47f142f54a (patch)
tree4175ed976f0e27a3045fe598a8d730e0760ace2e /include
parent04c8f4b56e59704558755865a5f4c2f0a94e5c96 (diff)
downloadplatform_external_python_pybind11-19189b4c2c7f205ae16fe9d0df121b47f142f54a.tar.gz
platform_external_python_pybind11-19189b4c2c7f205ae16fe9d0df121b47f142f54a.tar.bz2
platform_external_python_pybind11-19189b4c2c7f205ae16fe9d0df121b47f142f54a.zip
Make `overload_cast_impl` available in C++11 mode. (#1581)
* Make `overload_cast_impl` available in C++11 mode. Narrow the scope of the `#if defined(PYBIND11_CPP14)` block around overload_cast to only cover the parts where C++14 is stricly required. Thus, the implementation in `pybind11::details::overload_cast_impl` is still available in C++11 mode. * PR #1581: Modify test to use overload_cast_impl, update docs and change log
Diffstat (limited to 'include')
-rw-r--r--include/pybind11/detail/common.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h
index d31be9c..7fb427a 100644
--- a/include/pybind11/detail/common.h
+++ b/include/pybind11/detail/common.h
@@ -720,10 +720,6 @@ struct error_scope {
/// Dummy destructor wrapper that can be used to expose classes with a private destructor
struct nodelete { template <typename T> void operator()(T*) { } };
-// overload_cast requires variable templates: C++14
-#if defined(PYBIND11_CPP14)
-#define PYBIND11_OVERLOAD_CAST 1
-
NAMESPACE_BEGIN(detail)
template <typename... Args>
struct overload_cast_impl {
@@ -743,19 +739,23 @@ struct overload_cast_impl {
};
NAMESPACE_END(detail)
+// overload_cast requires variable templates: C++14
+#if defined(PYBIND11_CPP14)
+#define PYBIND11_OVERLOAD_CAST 1
/// Syntax sugar for resolving overloaded function pointers:
/// - regular: static_cast<Return (Class::*)(Arg0, Arg1, Arg2)>(&Class::func)
/// - sweet: overload_cast<Arg0, Arg1, Arg2>(&Class::func)
template <typename... Args>
static constexpr detail::overload_cast_impl<Args...> overload_cast = {};
// MSVC 2015 only accepts this particular initialization syntax for this variable template.
+#endif
/// Const member function selector for overload_cast
/// - regular: static_cast<Return (Class::*)(Arg) const>(&Class::func)
/// - sweet: overload_cast<Arg>(&Class::func, const_)
static constexpr auto const_ = std::true_type{};
-#else // no overload_cast: providing something that static_assert-fails:
+#if !defined(PYBIND11_CPP14) // no overload_cast: providing something that static_assert-fails:
template <typename... Args> struct overload_cast {
static_assert(detail::deferred_t<std::false_type, Args...>::value,
"pybind11::overload_cast<...> requires compiling in C++14 mode");