From ff783a150cbfd4ccd8ea46608c01037c88bfe797 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Fri, 22 Oct 2021 19:06:43 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20c=5Fstr=20is=20not=20a=20std::strin?= =?UTF-8?q?g=20and=20I=20fucking=20hate=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sol/detail/pairs.hpp | 1 + include/sol/stack_field.hpp | 12 ++++++------ include/sol/traits.hpp | 15 +++++++++++++-- include/sol/usertype_storage.hpp | 6 +++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/include/sol/detail/pairs.hpp b/include/sol/detail/pairs.hpp index fb88faa7..f6776cd0 100644 --- a/include/sol/detail/pairs.hpp +++ b/include/sol/detail/pairs.hpp @@ -28,6 +28,7 @@ #include #include +#include namespace sol { namespace stack { namespace stack_detail { diff --git a/include/sol/stack_field.hpp b/include/sol/stack_field.hpp index 9a184e0b..70b0903a 100644 --- a/include/sol/stack_field.hpp +++ b/include/sol/stack_field.hpp @@ -33,11 +33,11 @@ namespace sol { namespace stack { namespace stack_detail { template - inline constexpr bool is_get_direct_tableless_v = (global && !raw && meta::is_c_str_v); + inline constexpr bool is_get_direct_tableless_v = (global && !raw && meta::is_c_str_or_string_v); template inline constexpr bool is_get_direct_v = (is_get_direct_tableless_v) // cf-hack - || (!global && !raw && (meta::is_c_str_v || meta::is_string_of_v)) // cf-hack + || (!global && !raw && (meta::is_c_str_or_string_v || meta::is_string_of_v)) // cf-hack || (!global && raw && (std::is_integral_v && !std::is_same_v)) #if SOL_LUA_VERSION_I_ >= 503 || (!global && !raw && (std::is_integral_v && !std::is_same_v)) @@ -48,11 +48,11 @@ namespace sol { namespace stack { ; template - inline constexpr bool is_set_direct_tableless_v = (global && !raw && meta::is_c_str_v); + inline constexpr bool is_set_direct_tableless_v = (global && !raw && meta::is_c_str_or_string_v); template inline constexpr bool is_set_direct_v = (is_set_direct_tableless_v) // cf-hack - || (!global && !raw && (meta::is_c_str_v || meta::is_string_of_v)) // cf-hack + || (!global && !raw && (meta::is_c_str_or_string_v || meta::is_string_of_v)) // cf-hack || (!global && raw && (std::is_integral_v && !std::is_same_v)) // cf-hack #if SOL_LUA_VERSION_I_ >= 503 || (!global && !raw && (std::is_integral_v && !std::is_same_v)) @@ -107,7 +107,7 @@ namespace sol { namespace stack { } } else { - if constexpr (meta::is_c_str_v) { + if constexpr (meta::is_c_str_or_string_v) { if constexpr (global) { (void)tableindex; lua_getglobal(L, &key[0]); @@ -212,7 +212,7 @@ namespace sol { namespace stack { } } else { - if constexpr (meta::is_c_str_v || meta::is_string_of_v) { + if constexpr (meta::is_c_str_v) { if constexpr (global) { push(L, std::forward(value)); lua_setglobal(L, &key[0]); diff --git a/include/sol/traits.hpp b/include/sol/traits.hpp index fd062945..3e7ff4ce 100644 --- a/include/sol/traits.hpp +++ b/include/sol/traits.hpp @@ -678,8 +678,7 @@ namespace sol { namespace meta { struct is_pair> : std::true_type { }; template - using is_c_str_of = any, std::is_same, std::is_same, is_string_of, - is_string_literal_array_of>; + using is_c_str_of = any, std::is_same, std::is_same, is_string_literal_array_of>; template constexpr inline bool is_c_str_of_v = is_c_str_of::value; @@ -690,6 +689,18 @@ namespace sol { namespace meta { template constexpr inline bool is_c_str_v = is_c_str::value; + template + using is_c_str_or_string_of = any, is_string_of>; + + template + constexpr inline bool is_c_str_or_string_of_v = is_c_str_or_string_of::value; + + template + using is_c_str_or_string = is_c_str_or_string_of; + + template + constexpr inline bool is_c_str_or_string_v = is_c_str::value; + template struct is_move_only : all>, neg>>, std::is_move_constructible>> { }; diff --git a/include/sol/usertype_storage.hpp b/include/sol/usertype_storage.hpp index fdfac5ff..b8475134 100644 --- a/include/sol/usertype_storage.hpp +++ b/include/sol/usertype_storage.hpp @@ -66,11 +66,11 @@ namespace sol { namespace u_detail { template struct binding : binding_base { using uF = meta::unqualified_t; - using F = meta::conditional_t + using F = meta::conditional_t #if SOL_IS_ON(SOL_CHAR8_T_I_) - || meta::is_c_str_of_v + || meta::is_c_str_or_string_of_v #endif - || meta::is_c_str_of_v || meta::is_c_str_of_v || meta::is_c_str_of_v, + || meta::is_c_str_or_string_of_v || meta::is_c_str_or_string_of_v || meta::is_c_str_or_string_of_v, std::add_pointer_t>>, std::decay_t>; F data_;