Fix ambiguous overload for array vs. pointer

- Arrays vs. pointers continue to be the bane of my existence in working with """text""" in C++.
- Fixes #1001 and the issue that was ongoing in Mugen.
This commit is contained in:
ThePhD 2020-09-05 17:46:20 -04:00
parent 63df43e061
commit 275ae2c096
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
4 changed files with 30 additions and 26 deletions

View File

@ -746,7 +746,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<char> { struct unqualified_pusher<char> {
static int push(lua_State* L, char c) { static int push(lua_State* L, char c) {
const char str[2] = { c, '\0' }; const char str[2] = { c, '\0' };
return stack::push(L, str, 1); return stack::push(L, static_cast<const char*>(str), 1);
} }
}; };
@ -932,7 +932,7 @@ namespace sol { namespace stack {
} }
std::string u8str("", 0); std::string u8str("", 0);
u8str.resize(needed_size); u8str.resize(needed_size);
char* target = &u8str[0]; char* target = const_cast<char*>(u8str.data());
return convert_into(L, target, needed_size, strb, stre); return convert_into(L, target, needed_size, strb, stre);
} }
}; };
@ -1009,7 +1009,7 @@ namespace sol { namespace stack {
} }
std::string u8str("", 0); std::string u8str("", 0);
u8str.resize(needed_size); u8str.resize(needed_size);
char* target = &u8str[0]; char* target = const_cast<char*>(u8str.data());
return convert_into(L, target, needed_size, strb, stre); return convert_into(L, target, needed_size, strb, stre);
} }
}; };
@ -1042,7 +1042,8 @@ namespace sol { namespace stack {
} }
static int push(lua_State* L, const wchar_t (&str)[N], std::size_t sz) { static int push(lua_State* L, const wchar_t (&str)[N], std::size_t sz) {
return stack::push<const wchar_t*>(L, str, str + sz); const wchar_t* str_ptr = static_cast<const wchar_t*>(str);
return stack::push<const wchar_t*>(L, str_ptr, str_ptr + sz);
} }
}; };
@ -1053,7 +1054,8 @@ namespace sol { namespace stack {
} }
static int push(lua_State* L, const char16_t (&str)[N], std::size_t sz) { static int push(lua_State* L, const char16_t (&str)[N], std::size_t sz) {
return stack::push<const char16_t*>(L, str, str + sz); const char16_t* str_ptr = static_cast<const char16_t*>(str);
return stack::push<const char16_t*>(L, str_ptr, str_ptr + sz);
} }
}; };
@ -1064,7 +1066,8 @@ namespace sol { namespace stack {
} }
static int push(lua_State* L, const char32_t (&str)[N], std::size_t sz) { static int push(lua_State* L, const char32_t (&str)[N], std::size_t sz) {
return stack::push<const char32_t*>(L, str, str + sz); const char32_t* str_ptr = static_cast<const char32_t*>(str);
return stack::push<const char32_t*>(L, str_ptr, str_ptr + sz);
} }
}; };
@ -1072,7 +1075,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<wchar_t> { struct unqualified_pusher<wchar_t> {
static int push(lua_State* L, wchar_t c) { static int push(lua_State* L, wchar_t c) {
const wchar_t str[2] = { c, '\0' }; const wchar_t str[2] = { c, '\0' };
return stack::push(L, &str[0], 1); return stack::push(L, static_cast<const wchar_t*>(str), 1);
} }
}; };
@ -1080,7 +1083,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<char16_t> { struct unqualified_pusher<char16_t> {
static int push(lua_State* L, char16_t c) { static int push(lua_State* L, char16_t c) {
const char16_t str[2] = { c, '\0' }; const char16_t str[2] = { c, '\0' };
return stack::push(L, &str[0], 1); return stack::push(L, static_cast<const char16_t*>(str), 1);
} }
}; };
@ -1088,7 +1091,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<char32_t> { struct unqualified_pusher<char32_t> {
static int push(lua_State* L, char32_t c) { static int push(lua_State* L, char32_t c) {
const char32_t str[2] = { c, '\0' }; const char32_t str[2] = { c, '\0' };
return stack::push(L, &str[0], 1); return stack::push(L, static_cast<const char32_t*>(str), 1);
} }
}; };

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 2020-09-05 21:23:26.771012 UTC // Generated 2020-09-05 21:46:13.217176 UTC
// This header was generated with sol v3.2.1 (revision de87bec) // This header was generated with sol v3.2.1 (revision 63df43e)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_CONFIG_HPP #ifndef SOL_SINGLE_CONFIG_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 2020-09-05 21:23:26.767014 UTC // Generated 2020-09-05 21:46:13.213158 UTC
// This header was generated with sol v3.2.1 (revision de87bec) // This header was generated with sol v3.2.1 (revision 63df43e)
// 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 2020-09-05 21:23:26.587015 UTC // Generated 2020-09-05 21:46:13.049473 UTC
// This header was generated with sol v3.2.1 (revision de87bec) // This header was generated with sol v3.2.1 (revision 63df43e)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -9729,8 +9729,6 @@ namespace sol {
template <typename... Args> template <typename... Args>
std::size_t aligned_space_for(void* alignment = nullptr) { std::size_t aligned_space_for(void* alignment = nullptr) {
// use temporary storage to prevent strict UB shenanigans // use temporary storage to prevent strict UB shenanigans
using union_type = std::aligned_union<1, Args...>;
using union_type_t = typename union_type::type;
char alignment_shim[(std::max)({ sizeof(Args)... }) + (std::max)({ alignof(Args)... })] {}; char alignment_shim[(std::max)({ sizeof(Args)... }) + (std::max)({ alignof(Args)... })] {};
char* start = alignment == nullptr ? static_cast<char*>(alignment) : alignment_shim; char* start = alignment == nullptr ? static_cast<char*>(alignment) : alignment_shim;
(void)detail::swallow { int {}, (align_one(std::alignment_of_v<Args>, sizeof(Args), alignment), int {})... }; (void)detail::swallow { int {}, (align_one(std::alignment_of_v<Args>, sizeof(Args), alignment), int {})... };
@ -14022,7 +14020,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<char> { struct unqualified_pusher<char> {
static int push(lua_State* L, char c) { static int push(lua_State* L, char c) {
const char str[2] = { c, '\0' }; const char str[2] = { c, '\0' };
return stack::push(L, str, 1); return stack::push(L, static_cast<const char*>(str), 1);
} }
}; };
@ -14208,7 +14206,7 @@ namespace sol { namespace stack {
} }
std::string u8str("", 0); std::string u8str("", 0);
u8str.resize(needed_size); u8str.resize(needed_size);
char* target = &u8str[0]; char* target = const_cast<char*>(u8str.data());
return convert_into(L, target, needed_size, strb, stre); return convert_into(L, target, needed_size, strb, stre);
} }
}; };
@ -14285,7 +14283,7 @@ namespace sol { namespace stack {
} }
std::string u8str("", 0); std::string u8str("", 0);
u8str.resize(needed_size); u8str.resize(needed_size);
char* target = &u8str[0]; char* target = const_cast<char*>(u8str.data());
return convert_into(L, target, needed_size, strb, stre); return convert_into(L, target, needed_size, strb, stre);
} }
}; };
@ -14318,7 +14316,8 @@ namespace sol { namespace stack {
} }
static int push(lua_State* L, const wchar_t (&str)[N], std::size_t sz) { static int push(lua_State* L, const wchar_t (&str)[N], std::size_t sz) {
return stack::push<const wchar_t*>(L, str, str + sz); const wchar_t* str_ptr = static_cast<const wchar_t*>(str);
return stack::push<const wchar_t*>(L, str_ptr, str_ptr + sz);
} }
}; };
@ -14329,7 +14328,8 @@ namespace sol { namespace stack {
} }
static int push(lua_State* L, const char16_t (&str)[N], std::size_t sz) { static int push(lua_State* L, const char16_t (&str)[N], std::size_t sz) {
return stack::push<const char16_t*>(L, str, str + sz); const char16_t* str_ptr = static_cast<const char16_t*>(str);
return stack::push<const char16_t*>(L, str_ptr, str_ptr + sz);
} }
}; };
@ -14340,7 +14340,8 @@ namespace sol { namespace stack {
} }
static int push(lua_State* L, const char32_t (&str)[N], std::size_t sz) { static int push(lua_State* L, const char32_t (&str)[N], std::size_t sz) {
return stack::push<const char32_t*>(L, str, str + sz); const char32_t* str_ptr = static_cast<const char32_t*>(str);
return stack::push<const char32_t*>(L, str_ptr, str_ptr + sz);
} }
}; };
@ -14348,7 +14349,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<wchar_t> { struct unqualified_pusher<wchar_t> {
static int push(lua_State* L, wchar_t c) { static int push(lua_State* L, wchar_t c) {
const wchar_t str[2] = { c, '\0' }; const wchar_t str[2] = { c, '\0' };
return stack::push(L, &str[0], 1); return stack::push(L, static_cast<const wchar_t*>(str), 1);
} }
}; };
@ -14356,7 +14357,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<char16_t> { struct unqualified_pusher<char16_t> {
static int push(lua_State* L, char16_t c) { static int push(lua_State* L, char16_t c) {
const char16_t str[2] = { c, '\0' }; const char16_t str[2] = { c, '\0' };
return stack::push(L, &str[0], 1); return stack::push(L, static_cast<const char16_t*>(str), 1);
} }
}; };
@ -14364,7 +14365,7 @@ namespace sol { namespace stack {
struct unqualified_pusher<char32_t> { struct unqualified_pusher<char32_t> {
static int push(lua_State* L, char32_t c) { static int push(lua_State* L, char32_t c) {
const char32_t str[2] = { c, '\0' }; const char32_t str[2] = { c, '\0' };
return stack::push(L, &str[0], 1); return stack::push(L, static_cast<const char32_t*>(str), 1);
} }
}; };