/* tests/test_stl.cpp -- STL type casters Copyright (c) 2017 Wenzel Jakob All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. */ #include #include "constructor_stats.h" #include "pybind11_tests.h" #ifndef PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL # define PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL #endif #include #include #include #if defined(PYBIND11_TEST_BOOST) # include namespace pybind11 { namespace detail { template struct type_caster> : optional_caster> {}; template <> struct type_caster : void_caster {}; } // namespace detail } // namespace pybind11 #endif // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 #if defined(PYBIND11_HAS_VARIANT) using std::variant; #elif defined(PYBIND11_TEST_BOOST) # include # define PYBIND11_HAS_VARIANT 1 using boost::variant; namespace pybind11 { namespace detail { template struct type_caster> : variant_caster> {}; template <> struct visit_helper { template static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) { return boost::apply_visitor(args...); } }; } // namespace detail } // namespace pybind11 #endif PYBIND11_MAKE_OPAQUE(std::vector>); /// Issue #528: templated constructor struct TplCtorClass { template explicit TplCtorClass(const T &) {} bool operator==(const TplCtorClass &) const { return true; } }; namespace std { template <> struct hash { size_t operator()(const TplCtorClass &) const { return 0; } }; } // namespace std template