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
diff --git a/docs/classes.rst b/docs/classes.rst
index 1deec9b..a63f6a1 100644
--- a/docs/classes.rst
+++ b/docs/classes.rst
@@ -422,6 +422,17 @@
.def("foo_mutable", py::overload_cast<int, float>(&Widget::foo))
.def("foo_const", py::overload_cast<int, float>(&Widget::foo, py::const_));
+If you prefer the ``py::overload_cast`` syntax but have a C++11 compatible compiler only,
+you can use ``py::detail::overload_cast_impl`` with an additional set of parentheses:
+
+.. code-block:: cpp
+
+ template <typename... Args>
+ using overload_cast_ = pybind11::detail::overload_cast_impl<Args...>;
+
+ py::class_<Pet>(m, "Pet")
+ .def("set", overload_cast_<int>()(&Pet::set), "Set the pet's age")
+ .def("set", overload_cast_<const std::string &>()(&Pet::set), "Set the pet's name");
.. [#cpp14] A compiler which supports the ``-std=c++14`` flag
or Visual Studio 2015 Update 2 and newer.