Rework variant checks and other things to prevent hard failures.

This commit is contained in:
ThePhD 2019-12-01 19:27:49 -05:00
parent b0c74207d8
commit 38d979209d
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
5 changed files with 88 additions and 115 deletions

View File

@ -1365,7 +1365,7 @@ namespace sol {
template <typename T> template <typename T>
int default_to_string(lua_State* L) { int default_to_string(lua_State* L) {
return oss_default_to_string<T>(meta::supports_ostream_op<T>(), L); return oss_default_to_string<T>(meta::supports_op_ostream<T>(), L);
} }
template <typename T> template <typename T>

View File

@ -37,6 +37,9 @@
#include <array> #include <array>
#include <iterator> #include <iterator>
#include <iosfwd> #include <iosfwd>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#include <variant>
#endif // variant is weird on XCode, thanks XCode
namespace sol { namespace meta { namespace sol { namespace meta {
@ -459,39 +462,30 @@ namespace sol { namespace meta {
static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>; static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
}; };
#if defined(_MSC_VER) && _MSC_VER <= 1910 template <typename T, typename U, typename = void>
template <typename T, typename U, typename = decltype(std::declval<T&>() < std::declval<U&>())> class supports_op_less_test : public std::false_type {};
std::true_type supports_op_less_test(std::reference_wrapper<T>, std::reference_wrapper<U>); template <typename T, typename U>
std::false_type supports_op_less_test(...); class supports_op_less_test<T, U, void_t<decltype(std::declval<T&>() < std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
template <typename T, typename U, typename = decltype(std::declval<T&>() == std::declval<U&>())>
std::true_type supports_op_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>); template <typename T, typename U, typename = void>
std::false_type supports_op_equal_test(...); class supports_op_equal_test : public std::false_type {};
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())> template <typename T, typename U>
std::true_type supports_op_less_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>); class supports_op_equal_test<T, U, void_t<decltype(std::declval<T&>() == std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())> template <typename T, typename U, typename = void>
std::true_type supports_ostream_op(std::reference_wrapper<const T>, std::reference_wrapper<OS>); class supports_op_less_equal_test : public std::false_type {};
std::false_type supports_ostream_op(...); template <typename T, typename U>
template <typename T, typename = decltype(to_string(std::declval<T&>()))> class supports_op_less_equal_test<T, U, void_t<decltype(std::declval<T&>() <= std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
std::true_type supports_adl_to_string(std::reference_wrapper<T>);
std::false_type supports_adl_to_string(...); template <typename T, typename U, typename = void>
#else class supports_op_ostream_test : public std::false_type {};
template <typename T, typename U, typename = decltype(std::declval<T&>() < std::declval<U&>())> template <typename T, typename U>
std::true_type supports_op_less_test(const T&, const U&); class supports_op_ostream_test<T, U, void_t<decltype(std::declval<T&>() << std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
std::false_type supports_op_less_test(...);
template <typename T, typename U, typename = decltype(std::declval<T&>() == std::declval<U&>())> template <typename T, typename = void>
std::true_type supports_op_equal_test(const T&, const U&); class supports_adl_to_string_test : public std::false_type {};
std::false_type supports_op_equal_test(...); template <typename T>
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())> class supports_adl_to_string_test<T, void_t<decltype(to_string(std::declval<const T&>()))>> : public std::true_type {};
std::true_type supports_op_less_equal_test(const T&, const U&);
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())>
std::true_type supports_ostream_op(const T&, const OS&);
std::false_type supports_ostream_op(...);
template <typename T, typename = decltype(to_string(std::declval<T&>()))>
std::true_type supports_adl_to_string(const T&);
std::false_type supports_adl_to_string(...);
#endif
template <typename T, bool b> template <typename T, bool b>
struct is_matched_lookup_impl : std::false_type {}; struct is_matched_lookup_impl : std::false_type {};
@ -503,22 +497,22 @@ namespace sol { namespace meta {
} // namespace meta_detail } // namespace meta_detail
template <typename T, typename U = T> template <typename T, typename U = T>
using supports_op_less class supports_op_less : public meta_detail::supports_op_less_test<T, U> {};
= decltype(meta_detail::supports_op_less_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = T> template <typename T, typename U = T>
using supports_op_equal class supports_op_equal : public meta_detail::supports_op_equal_test<T, U> {};
= decltype(meta_detail::supports_op_equal_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = T> template <typename T, typename U = T>
using supports_op_less_equal class supports_op_less_equal : public meta_detail::supports_op_less_equal_test<T, U> {};
= decltype(meta_detail::supports_op_less_equal_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = std::ostream> template <typename T, typename U = T>
using supports_ostream_op class supports_op_ostream : public meta_detail::supports_op_ostream_test<T, U> {};
= decltype(meta_detail::supports_ostream_op(std::declval<meta_detail::non_void_t<T>&>(), std::declval<const meta_detail::non_void_t<U>&>()));
template <typename T>
using supports_adl_to_string = decltype(meta_detail::supports_adl_to_string(std::declval<meta_detail::non_void_t<T>&>()));
template <typename T> template <typename T>
using supports_to_string_member = meta::boolean<meta_detail::has_to_string_test<meta_detail::non_void_t<T>>::value>; class supports_adl_to_string : public meta_detail::supports_adl_to_string_test<T> {};
template <typename T>
class supports_to_string_member : public meta::boolean<meta_detail::has_to_string_test<meta_detail::non_void_t<T>>::value> {};
template <typename T> template <typename T>
using is_callable = boolean<meta_detail::is_callable<T>::value>; using is_callable = boolean<meta_detail::is_callable<T>::value>;

View File

@ -908,7 +908,7 @@ namespace sol {
template <typename T> template <typename T>
struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>, struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>,
meta::supports_ostream_op<meta::unqualified_t<T>>> {}; meta::supports_op_ostream<meta::unqualified_t<T>>> {};
namespace detail { namespace detail {
template <typename T, typename = void> template <typename T, typename = void>
@ -1307,14 +1307,7 @@ namespace sol {
template <typename T> template <typename T>
struct is_automagical struct is_automagical
: std::integral_constant<bool, : std::integral_constant<bool, std::is_array_v<meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>)> {
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
!meta::is_specialization_of_v<meta::unqualified_t<T>, std::variant> &&
#endif // std::variant borked in places
#endif // C++17 Features
std::is_array_v<
meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>)> {
}; };
template <typename T> template <typename T>

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2019-12-01 22:39:33.269777 UTC // Generated 2019-12-02 00:27:36.626106 UTC
// This header was generated with sol v3.2.0 (revision e26475e) // This header was generated with sol v3.2.0 (revision b0c7420)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2019-12-01 22:39:31.432773 UTC // Generated 2019-12-02 00:27:35.949915 UTC
// This header was generated with sol v3.2.0 (revision e26475e) // This header was generated with sol v3.2.0 (revision b0c7420)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -1412,6 +1412,9 @@ namespace sol {
#include <array> #include <array>
#include <iterator> #include <iterator>
#include <iosfwd> #include <iosfwd>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#include <variant>
#endif // variant is weird on XCode, thanks XCode
namespace sol { namespace meta { namespace sol { namespace meta {
template <typename T> template <typename T>
@ -1833,39 +1836,30 @@ namespace sol { namespace meta {
static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>; static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
}; };
#if defined(_MSC_VER) && _MSC_VER <= 1910 template <typename T, typename U, typename = void>
template <typename T, typename U, typename = decltype(std::declval<T&>() < std::declval<U&>())> class supports_op_less_test : public std::false_type {};
std::true_type supports_op_less_test(std::reference_wrapper<T>, std::reference_wrapper<U>); template <typename T, typename U>
std::false_type supports_op_less_test(...); class supports_op_less_test<T, U, void_t<decltype(std::declval<T&>() < std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
template <typename T, typename U, typename = decltype(std::declval<T&>() == std::declval<U&>())>
std::true_type supports_op_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>); template <typename T, typename U, typename = void>
std::false_type supports_op_equal_test(...); class supports_op_equal_test : public std::false_type {};
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())> template <typename T, typename U>
std::true_type supports_op_less_equal_test(std::reference_wrapper<T>, std::reference_wrapper<U>); class supports_op_equal_test<T, U, void_t<decltype(std::declval<T&>() == std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())> template <typename T, typename U, typename = void>
std::true_type supports_ostream_op(std::reference_wrapper<const T>, std::reference_wrapper<OS>); class supports_op_less_equal_test : public std::false_type {};
std::false_type supports_ostream_op(...); template <typename T, typename U>
template <typename T, typename = decltype(to_string(std::declval<T&>()))> class supports_op_less_equal_test<T, U, void_t<decltype(std::declval<T&>() <= std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
std::true_type supports_adl_to_string(std::reference_wrapper<T>);
std::false_type supports_adl_to_string(...); template <typename T, typename U, typename = void>
#else class supports_op_ostream_test : public std::false_type {};
template <typename T, typename U, typename = decltype(std::declval<T&>() < std::declval<U&>())> template <typename T, typename U>
std::true_type supports_op_less_test(const T&, const U&); class supports_op_ostream_test<T, U, void_t<decltype(std::declval<T&>() << std::declval<U&>())>> : public std::integral_constant<bool, !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>> {};
std::false_type supports_op_less_test(...);
template <typename T, typename U, typename = decltype(std::declval<T&>() == std::declval<U&>())> template <typename T, typename = void>
std::true_type supports_op_equal_test(const T&, const U&); class supports_adl_to_string_test : public std::false_type {};
std::false_type supports_op_equal_test(...); template <typename T>
template <typename T, typename U, typename = decltype(std::declval<T&>() <= std::declval<U&>())> class supports_adl_to_string_test<T, void_t<decltype(to_string(std::declval<const T&>()))>> : public std::true_type {};
std::true_type supports_op_less_equal_test(const T&, const U&);
std::false_type supports_op_less_equal_test(...);
template <typename T, typename OS, typename = decltype(std::declval<OS&>() << std::declval<const T&>())>
std::true_type supports_ostream_op(const T&, const OS&);
std::false_type supports_ostream_op(...);
template <typename T, typename = decltype(to_string(std::declval<T&>()))>
std::true_type supports_adl_to_string(const T&);
std::false_type supports_adl_to_string(...);
#endif
template <typename T, bool b> template <typename T, bool b>
struct is_matched_lookup_impl : std::false_type {}; struct is_matched_lookup_impl : std::false_type {};
@ -1877,22 +1871,22 @@ namespace sol { namespace meta {
} // namespace meta_detail } // namespace meta_detail
template <typename T, typename U = T> template <typename T, typename U = T>
using supports_op_less class supports_op_less : public meta_detail::supports_op_less_test<T, U> {};
= decltype(meta_detail::supports_op_less_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = T> template <typename T, typename U = T>
using supports_op_equal class supports_op_equal : public meta_detail::supports_op_equal_test<T, U> {};
= decltype(meta_detail::supports_op_equal_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = T> template <typename T, typename U = T>
using supports_op_less_equal class supports_op_less_equal : public meta_detail::supports_op_less_equal_test<T, U> {};
= decltype(meta_detail::supports_op_less_equal_test(std::declval<meta_detail::non_void_t<T>&>(), std::declval<meta_detail::non_void_t<U>&>()));
template <typename T, typename U = std::ostream> template <typename T, typename U = T>
using supports_ostream_op class supports_op_ostream : public meta_detail::supports_op_ostream_test<T, U> {};
= decltype(meta_detail::supports_ostream_op(std::declval<meta_detail::non_void_t<T>&>(), std::declval<const meta_detail::non_void_t<U>&>()));
template <typename T>
using supports_adl_to_string = decltype(meta_detail::supports_adl_to_string(std::declval<meta_detail::non_void_t<T>&>()));
template <typename T> template <typename T>
using supports_to_string_member = meta::boolean<meta_detail::has_to_string_test<meta_detail::non_void_t<T>>::value>; class supports_adl_to_string : public meta_detail::supports_adl_to_string_test<T> {};
template <typename T>
class supports_to_string_member : public meta::boolean<meta_detail::has_to_string_test<meta_detail::non_void_t<T>>::value> {};
template <typename T> template <typename T>
using is_callable = boolean<meta_detail::is_callable<T>::value>; using is_callable = boolean<meta_detail::is_callable<T>::value>;
@ -6297,7 +6291,6 @@ namespace sol { namespace detail {
#include <initializer_list> #include <initializer_list>
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#ifdef SOL_STD_VARIANT #ifdef SOL_STD_VARIANT
#include <variant>
#endif #endif
#endif // C++17 #endif // C++17
#ifdef SOL_USE_BOOST #ifdef SOL_USE_BOOST
@ -7163,7 +7156,7 @@ namespace sol {
template <typename T> template <typename T>
struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>, struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>,
meta::supports_ostream_op<meta::unqualified_t<T>>> {}; meta::supports_op_ostream<meta::unqualified_t<T>>> {};
namespace detail { namespace detail {
template <typename T, typename = void> template <typename T, typename = void>
@ -7561,14 +7554,7 @@ namespace sol {
template <typename T> template <typename T>
struct is_automagical struct is_automagical
: std::integral_constant<bool, : std::integral_constant<bool, std::is_array_v<meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>)> {
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
!meta::is_specialization_of_v<meta::unqualified_t<T>, std::variant> &&
#endif // std::variant borked in places
#endif // C++17 Features
std::is_array_v<
meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>)> {
}; };
template <typename T> template <typename T>
@ -10814,7 +10800,7 @@ namespace sol {
template <typename T> template <typename T>
int default_to_string(lua_State* L) { int default_to_string(lua_State* L) {
return oss_default_to_string<T>(meta::supports_ostream_op<T>(), L); return oss_default_to_string<T>(meta::supports_op_ostream<T>(), L);
} }
template <typename T> template <typename T>