From fb50ce1fefb047a8497f158d4020e579f62b7855 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sun, 16 Apr 2017 21:58:29 -0400 Subject: [PATCH] Add static_assert-raising error for overload_cast in c++11 I got some unexpected errors from code using `overload_cast` until I realized that I'd configured the build with -std=c++11. This commit adds a fake `overload_cast` class in C++11 mode that triggers a static_assert failure indicating that C++14 is needed. --- include/pybind11/common.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/pybind11/common.h b/include/pybind11/common.h index e08c56b55..eb6941002 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -655,6 +655,11 @@ static constexpr detail::overload_cast_impl overload_cast = {}; /// - sweet: overload_cast(&Class::func, const_) static constexpr auto const_ = std::true_type{}; +#else // no overload_cast: providing something that static_assert-fails: +template struct overload_cast { + static_assert(detail::deferred_t::value, + "pybind11::overload_cast<...> requires compiling in C++14 mode"); +}; #endif // overload_cast NAMESPACE_BEGIN(detail)