Add support for boost::variant in C++11 mode
In C++11 mode, `boost::apply_visitor` requires an explicit `result_type`.
This also adds optional tests for `boost::variant` in C++11/14, if boost
is available. In C++17 mode, `std::variant` is tested instead.
diff --git a/docs/advanced/cast/stl.rst b/docs/advanced/cast/stl.rst
index ac6318f..2d709d7 100644
--- a/docs/advanced/cast/stl.rst
+++ b/docs/advanced/cast/stl.rst
@@ -60,8 +60,7 @@
template <>
struct visit_helper<boost::variant> {
template <typename... Args>
- static auto call(Args &&...args)
- -> decltype(boost::apply_visitor(args...)) {
+ static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) {
return boost::apply_visitor(args...);
}
};
@@ -71,6 +70,13 @@
a ``name::visit()`` function. For any other function name, the specialization must be
included to tell pybind11 how to visit the variant.
+.. note::
+
+ pybind11 only supports the modern implementation of ``boost::variant``
+ which makes use of variadic templates. This requires Boost 1.56 or newer.
+ Additionally, on Windows, MSVC 2017 is required because ``boost::variant``
+ falls back to the old non-variadic implementation on MSVC 2015.
+
.. _opaque:
Making opaque types