mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
more minor fixes for bad trait usage, wee
This commit is contained in:
parent
c3c08df787
commit
e03f53d4dc
|
@ -64,7 +64,8 @@ namespace sol {
|
||||||
struct has_erase_after_test {
|
struct has_erase_after_test {
|
||||||
private:
|
private:
|
||||||
template <typename C>
|
template <typename C>
|
||||||
static meta::sfinae_yes_t test(decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
|
static meta::sfinae_yes_t test(
|
||||||
|
decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
|
||||||
template <typename C>
|
template <typename C>
|
||||||
static meta::sfinae_no_t test(...);
|
static meta::sfinae_no_t test(...);
|
||||||
|
|
||||||
|
@ -404,7 +405,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int index_set(lua_State* L) {
|
static int index_set(lua_State* L) {
|
||||||
return luaL_error(L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
|
return luaL_error(
|
||||||
|
L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add(lua_State* L) {
|
static int add(lua_State* L) {
|
||||||
|
@ -463,7 +465,9 @@ namespace sol {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename X>
|
template <typename X>
|
||||||
struct usertype_container_default<X, std::enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>, meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
|
struct usertype_container_default<X,
|
||||||
|
std::enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>,
|
||||||
|
meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
|
||||||
private:
|
private:
|
||||||
using T = std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>;
|
using T = std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>;
|
||||||
|
|
||||||
|
@ -475,32 +479,21 @@ namespace sol {
|
||||||
using is_matched_lookup = meta::is_matched_lookup<T>;
|
using is_matched_lookup = meta::is_matched_lookup<T>;
|
||||||
using iterator = typename T::iterator;
|
using iterator = typename T::iterator;
|
||||||
using value_type = typename T::value_type;
|
using value_type = typename T::value_type;
|
||||||
typedef meta::conditional_t<is_matched_lookup::value,
|
typedef meta::conditional_t<is_matched_lookup::value, std::pair<value_type, value_type>,
|
||||||
std::pair<value_type, value_type>,
|
meta::conditional_t<is_associative::value || is_lookup::value, value_type, std::pair<std::ptrdiff_t, value_type>>>
|
||||||
meta::conditional_t<is_associative::value || is_lookup::value,
|
|
||||||
value_type,
|
|
||||||
std::pair<std::ptrdiff_t, value_type>>>
|
|
||||||
KV;
|
KV;
|
||||||
typedef typename KV::first_type K;
|
typedef typename KV::first_type K;
|
||||||
typedef typename KV::second_type V;
|
typedef typename KV::second_type V;
|
||||||
typedef meta::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K> next_K;
|
typedef meta::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K> next_K;
|
||||||
typedef decltype(*std::declval<iterator&>()) iterator_return;
|
typedef decltype(*std::declval<iterator&>()) iterator_return;
|
||||||
typedef meta::conditional_t<is_associative::value || is_matched_lookup::value,
|
typedef meta::conditional_t<is_associative::value || is_matched_lookup::value, std::add_lvalue_reference_t<V>,
|
||||||
std::add_lvalue_reference_t<V>,
|
meta::conditional_t<is_lookup::value, V, iterator_return>>
|
||||||
meta::conditional_t<is_lookup::value,
|
|
||||||
V,
|
|
||||||
iterator_return>>
|
|
||||||
captured_type;
|
captured_type;
|
||||||
typedef typename meta::iterator_tag<iterator>::type iterator_category;
|
typedef typename meta::iterator_tag<iterator>::type iterator_category;
|
||||||
typedef std::is_same<iterator_category, std::input_iterator_tag> is_input_iterator;
|
typedef std::is_same<iterator_category, std::input_iterator_tag> is_input_iterator;
|
||||||
typedef meta::conditional_t<is_input_iterator::value,
|
typedef meta::conditional_t<is_input_iterator::value, V, decltype(detail::deref_non_pointer(std::declval<captured_type>()))> push_type;
|
||||||
V,
|
|
||||||
decltype(detail::deref_non_pointer(std::declval<captured_type>()))>
|
|
||||||
push_type;
|
|
||||||
typedef std::is_copy_assignable<V> is_copyable;
|
typedef std::is_copy_assignable<V> is_copyable;
|
||||||
typedef meta::neg<meta::any<
|
typedef meta::neg<meta::any<std::is_const<V>, std::is_const<std::remove_reference_t<iterator_return>>, meta::neg<is_copyable>>> is_writable;
|
||||||
std::is_const<V>, std::is_const<std::remove_reference_t<iterator_return>>, meta::neg<is_copyable>>>
|
|
||||||
is_writable;
|
|
||||||
typedef meta::unqualified_t<decltype(get_key(is_associative(), std::declval<std::add_lvalue_reference_t<value_type>>()))> key_type;
|
typedef meta::unqualified_t<decltype(get_key(is_associative(), std::declval<std::add_lvalue_reference_t<value_type>>()))> key_type;
|
||||||
typedef meta::all<std::is_integral<K>, meta::neg<meta::any<is_associative, is_lookup>>> is_linear_integral;
|
typedef meta::all<std::is_integral<K>, meta::neg<meta::any<is_associative, is_lookup>>> is_linear_integral;
|
||||||
|
|
||||||
|
@ -509,12 +502,10 @@ namespace sol {
|
||||||
iterator it;
|
iterator it;
|
||||||
std::size_t i;
|
std::size_t i;
|
||||||
|
|
||||||
iter(T& source, iterator it)
|
iter(T& source, iterator it) : source(source), it(std::move(it)), i(0) {
|
||||||
: source(source), it(std::move(it)), i(0) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~iter() {
|
~iter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -522,10 +513,13 @@ namespace sol {
|
||||||
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
||||||
auto p = stack::unqualified_check_get<T*>(L, 1);
|
auto p = stack::unqualified_check_get<T*>(L, 1);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
|
luaL_error(L,
|
||||||
|
"sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
|
||||||
|
detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
if (p.value() == nullptr) {
|
if (p.value() == nullptr) {
|
||||||
luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
luaL_error(
|
||||||
|
L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
return *p.value();
|
return *p.value();
|
||||||
#else
|
#else
|
||||||
|
@ -613,9 +607,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_comparative(std::true_type, lua_State* L, T& self, K& key) {
|
static detail::error_result get_comparative(std::true_type, lua_State* L, T& self, K& key) {
|
||||||
auto fx = [&](const value_type& r) -> bool {
|
auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); };
|
||||||
return key == get_key(is_associative(), r);
|
|
||||||
};
|
|
||||||
auto e = deferred_uc::end(L, self);
|
auto e = deferred_uc::end(L, self);
|
||||||
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
||||||
if (it == e) {
|
if (it == e) {
|
||||||
|
@ -625,7 +617,9 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_comparative(std::false_type, lua_State*, T&, K&) {
|
static detail::error_result get_comparative(std::false_type, lua_State*, T&, K&) {
|
||||||
return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", detail::demangle<T>().data(), detail::demangle<K>().data());
|
return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'",
|
||||||
|
detail::demangle<T>().data(),
|
||||||
|
detail::demangle<K>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_it(std::false_type, lua_State* L, T& self, K& key) {
|
static detail::error_result get_it(std::false_type, lua_State* L, T& self, K& key) {
|
||||||
|
@ -649,7 +643,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_writable(std::false_type, lua_State*, T&, iterator&, stack_object) {
|
static detail::error_result set_writable(std::false_type, lua_State*, T&, iterator&, stack_object) {
|
||||||
return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
return detail::error_result(
|
||||||
|
"cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_category(std::input_iterator_tag, lua_State* L, T& self, stack_object okey, stack_object value) {
|
static detail::error_result set_category(std::input_iterator_tag, lua_State* L, T& self, stack_object okey, stack_object value) {
|
||||||
|
@ -690,11 +685,10 @@ namespace sol {
|
||||||
static detail::error_result set_comparative(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) {
|
static detail::error_result set_comparative(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) {
|
||||||
decltype(auto) key = okey.as<K>();
|
decltype(auto) key = okey.as<K>();
|
||||||
if (!is_writable::value) {
|
if (!is_writable::value) {
|
||||||
return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
return detail::error_result(
|
||||||
|
"cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
||||||
}
|
}
|
||||||
auto fx = [&](const value_type& r) -> bool {
|
auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); };
|
||||||
return key == get_key(is_associative(), r);
|
|
||||||
};
|
|
||||||
auto e = deferred_uc::end(L, self);
|
auto e = deferred_uc::end(L, self);
|
||||||
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
||||||
if (it == e) {
|
if (it == e) {
|
||||||
|
@ -704,12 +698,14 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_comparative(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
static detail::error_result set_comparative(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
||||||
return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", detail::demangle<T>().data(), detail::demangle<K>().data());
|
return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key",
|
||||||
|
detail::demangle<T>().data(),
|
||||||
|
detail::demangle<K>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) {
|
static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) {
|
||||||
if constexpr(meta::has_insert<T>::value) {
|
if constexpr (meta::has_insert<T>::value) {
|
||||||
self.insert(it, value_type(key, value.as<V>()));
|
self.insert(it, value_type(key, value.as<V>()));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -717,13 +713,14 @@ namespace sol {
|
||||||
(void)self;
|
(void)self;
|
||||||
(void)it;
|
(void)it;
|
||||||
(void)key;
|
(void)key;
|
||||||
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
return detail::error_result(
|
||||||
|
"cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) {
|
static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) {
|
||||||
if constexpr(has_insert<T>::value) {
|
if constexpr (meta::has_insert<T>::value) {
|
||||||
self.insert(it, key);
|
self.insert(it, key);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -731,7 +728,8 @@ namespace sol {
|
||||||
(void)self;
|
(void)self;
|
||||||
(void)it;
|
(void)it;
|
||||||
(void)key;
|
(void)key;
|
||||||
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
|
return detail::error_result(
|
||||||
|
"cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,7 +820,8 @@ namespace sol {
|
||||||
|
|
||||||
template <bool = false>
|
template <bool = false>
|
||||||
static detail::error_result find_comparative(std::false_type, lua_State*, T&) {
|
static detail::error_result find_comparative(std::false_type, lua_State*, T&) {
|
||||||
return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", detail::demangle<T>().c_str());
|
return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable",
|
||||||
|
detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool idx_of = false>
|
template <bool idx_of = false>
|
||||||
|
@ -914,7 +913,7 @@ namespace sol {
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) {
|
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) {
|
||||||
if constexpr(meta::has_insert<T>::value) {
|
if constexpr (meta::has_insert<T>::value) {
|
||||||
self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L, 3)));
|
self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L, 3)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -923,7 +922,8 @@ namespace sol {
|
||||||
(void)self;
|
(void)self;
|
||||||
(void)key;
|
(void)key;
|
||||||
(void)pos;
|
(void)pos;
|
||||||
return detail::error_result("cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
return detail::error_result(
|
||||||
|
"cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -990,7 +990,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result insert_after_has(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
static detail::error_result insert_after_has(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
||||||
return detail::error_result("cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().data());
|
return detail::error_result(
|
||||||
|
"cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) {
|
static detail::error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) {
|
||||||
|
@ -1019,9 +1020,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result erase_integral(std::false_type, lua_State* L, T& self, const K& key) {
|
static detail::error_result erase_integral(std::false_type, lua_State* L, T& self, const K& key) {
|
||||||
auto fx = [&](const value_type& r) -> bool {
|
auto fx = [&](const value_type& r) -> bool { return key == r; };
|
||||||
return key == r;
|
|
||||||
};
|
|
||||||
auto e = deferred_uc::end(L, self);
|
auto e = deferred_uc::end(L, self);
|
||||||
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
||||||
if (it == e) {
|
if (it == e) {
|
||||||
|
@ -1106,7 +1105,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_start(lua_State* L, T& self, K& key) {
|
static detail::error_result get_start(lua_State* L, T& self, K& key) {
|
||||||
return get_associative_find(std::integral_constant<bool, is_associative::value && has_find<T>::value>(), L, self, key);
|
return get_associative_find(std::integral_constant < bool, is_associative::value&& has_find<T>::value > (), L, self, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) {
|
static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) {
|
||||||
|
@ -1333,8 +1332,7 @@ namespace sol {
|
||||||
T& source;
|
T& source;
|
||||||
iterator it;
|
iterator it;
|
||||||
|
|
||||||
iter(T& source, iterator it)
|
iter(T& source, iterator it) : source(source), it(std::move(it)) {
|
||||||
: source(source), it(std::move(it)) {
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1342,10 +1340,13 @@ namespace sol {
|
||||||
auto p = stack::unqualified_check_get<T*>(L, 1);
|
auto p = stack::unqualified_check_get<T*>(L, 1);
|
||||||
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
||||||
if (!p) {
|
if (!p) {
|
||||||
luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
|
luaL_error(L,
|
||||||
|
"sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
|
||||||
|
detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
if (p.value() == nullptr) {
|
if (p.value() == nullptr) {
|
||||||
luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
luaL_error(
|
||||||
|
L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
#endif // Safe getting with error
|
#endif // Safe getting with error
|
||||||
return *p.value();
|
return *p.value();
|
||||||
|
|
|
@ -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-08-15 06:28:23.273623 UTC
|
// Generated 2019-08-15 12:13:47.368988 UTC
|
||||||
// This header was generated with sol v3.0.3 (revision cb3acaa)
|
// This header was generated with sol v3.0.3 (revision c3c08df)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||||
|
|
|
@ -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-08-15 06:28:22.668458 UTC
|
// Generated 2019-08-15 12:13:46.408546 UTC
|
||||||
// This header was generated with sol v3.0.3 (revision cb3acaa)
|
// This header was generated with sol v3.0.3 (revision c3c08df)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
|
@ -19027,7 +19027,8 @@ namespace sol {
|
||||||
struct has_erase_after_test {
|
struct has_erase_after_test {
|
||||||
private:
|
private:
|
||||||
template <typename C>
|
template <typename C>
|
||||||
static meta::sfinae_yes_t test(decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
|
static meta::sfinae_yes_t test(
|
||||||
|
decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
|
||||||
template <typename C>
|
template <typename C>
|
||||||
static meta::sfinae_no_t test(...);
|
static meta::sfinae_no_t test(...);
|
||||||
|
|
||||||
|
@ -19367,7 +19368,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int index_set(lua_State* L) {
|
static int index_set(lua_State* L) {
|
||||||
return luaL_error(L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
|
return luaL_error(
|
||||||
|
L, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add(lua_State* L) {
|
static int add(lua_State* L) {
|
||||||
|
@ -19426,7 +19428,9 @@ namespace sol {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename X>
|
template <typename X>
|
||||||
struct usertype_container_default<X, std::enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>, meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
|
struct usertype_container_default<X,
|
||||||
|
std::enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>,
|
||||||
|
meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
|
||||||
private:
|
private:
|
||||||
using T = std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>;
|
using T = std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>;
|
||||||
|
|
||||||
|
@ -19438,32 +19442,21 @@ namespace sol {
|
||||||
using is_matched_lookup = meta::is_matched_lookup<T>;
|
using is_matched_lookup = meta::is_matched_lookup<T>;
|
||||||
using iterator = typename T::iterator;
|
using iterator = typename T::iterator;
|
||||||
using value_type = typename T::value_type;
|
using value_type = typename T::value_type;
|
||||||
typedef meta::conditional_t<is_matched_lookup::value,
|
typedef meta::conditional_t<is_matched_lookup::value, std::pair<value_type, value_type>,
|
||||||
std::pair<value_type, value_type>,
|
meta::conditional_t<is_associative::value || is_lookup::value, value_type, std::pair<std::ptrdiff_t, value_type>>>
|
||||||
meta::conditional_t<is_associative::value || is_lookup::value,
|
|
||||||
value_type,
|
|
||||||
std::pair<std::ptrdiff_t, value_type>>>
|
|
||||||
KV;
|
KV;
|
||||||
typedef typename KV::first_type K;
|
typedef typename KV::first_type K;
|
||||||
typedef typename KV::second_type V;
|
typedef typename KV::second_type V;
|
||||||
typedef meta::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K> next_K;
|
typedef meta::conditional_t<is_matched_lookup::value, std::ptrdiff_t, K> next_K;
|
||||||
typedef decltype(*std::declval<iterator&>()) iterator_return;
|
typedef decltype(*std::declval<iterator&>()) iterator_return;
|
||||||
typedef meta::conditional_t<is_associative::value || is_matched_lookup::value,
|
typedef meta::conditional_t<is_associative::value || is_matched_lookup::value, std::add_lvalue_reference_t<V>,
|
||||||
std::add_lvalue_reference_t<V>,
|
meta::conditional_t<is_lookup::value, V, iterator_return>>
|
||||||
meta::conditional_t<is_lookup::value,
|
|
||||||
V,
|
|
||||||
iterator_return>>
|
|
||||||
captured_type;
|
captured_type;
|
||||||
typedef typename meta::iterator_tag<iterator>::type iterator_category;
|
typedef typename meta::iterator_tag<iterator>::type iterator_category;
|
||||||
typedef std::is_same<iterator_category, std::input_iterator_tag> is_input_iterator;
|
typedef std::is_same<iterator_category, std::input_iterator_tag> is_input_iterator;
|
||||||
typedef meta::conditional_t<is_input_iterator::value,
|
typedef meta::conditional_t<is_input_iterator::value, V, decltype(detail::deref_non_pointer(std::declval<captured_type>()))> push_type;
|
||||||
V,
|
|
||||||
decltype(detail::deref_non_pointer(std::declval<captured_type>()))>
|
|
||||||
push_type;
|
|
||||||
typedef std::is_copy_assignable<V> is_copyable;
|
typedef std::is_copy_assignable<V> is_copyable;
|
||||||
typedef meta::neg<meta::any<
|
typedef meta::neg<meta::any<std::is_const<V>, std::is_const<std::remove_reference_t<iterator_return>>, meta::neg<is_copyable>>> is_writable;
|
||||||
std::is_const<V>, std::is_const<std::remove_reference_t<iterator_return>>, meta::neg<is_copyable>>>
|
|
||||||
is_writable;
|
|
||||||
typedef meta::unqualified_t<decltype(get_key(is_associative(), std::declval<std::add_lvalue_reference_t<value_type>>()))> key_type;
|
typedef meta::unqualified_t<decltype(get_key(is_associative(), std::declval<std::add_lvalue_reference_t<value_type>>()))> key_type;
|
||||||
typedef meta::all<std::is_integral<K>, meta::neg<meta::any<is_associative, is_lookup>>> is_linear_integral;
|
typedef meta::all<std::is_integral<K>, meta::neg<meta::any<is_associative, is_lookup>>> is_linear_integral;
|
||||||
|
|
||||||
|
@ -19472,12 +19465,10 @@ namespace sol {
|
||||||
iterator it;
|
iterator it;
|
||||||
std::size_t i;
|
std::size_t i;
|
||||||
|
|
||||||
iter(T& source, iterator it)
|
iter(T& source, iterator it) : source(source), it(std::move(it)), i(0) {
|
||||||
: source(source), it(std::move(it)), i(0) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~iter() {
|
~iter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19485,10 +19476,13 @@ namespace sol {
|
||||||
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
||||||
auto p = stack::unqualified_check_get<T*>(L, 1);
|
auto p = stack::unqualified_check_get<T*>(L, 1);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
|
luaL_error(L,
|
||||||
|
"sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
|
||||||
|
detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
if (p.value() == nullptr) {
|
if (p.value() == nullptr) {
|
||||||
luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
luaL_error(
|
||||||
|
L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
return *p.value();
|
return *p.value();
|
||||||
#else
|
#else
|
||||||
|
@ -19576,9 +19570,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_comparative(std::true_type, lua_State* L, T& self, K& key) {
|
static detail::error_result get_comparative(std::true_type, lua_State* L, T& self, K& key) {
|
||||||
auto fx = [&](const value_type& r) -> bool {
|
auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); };
|
||||||
return key == get_key(is_associative(), r);
|
|
||||||
};
|
|
||||||
auto e = deferred_uc::end(L, self);
|
auto e = deferred_uc::end(L, self);
|
||||||
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
||||||
if (it == e) {
|
if (it == e) {
|
||||||
|
@ -19588,7 +19580,9 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_comparative(std::false_type, lua_State*, T&, K&) {
|
static detail::error_result get_comparative(std::false_type, lua_State*, T&, K&) {
|
||||||
return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'", detail::demangle<T>().data(), detail::demangle<K>().data());
|
return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'",
|
||||||
|
detail::demangle<T>().data(),
|
||||||
|
detail::demangle<K>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_it(std::false_type, lua_State* L, T& self, K& key) {
|
static detail::error_result get_it(std::false_type, lua_State* L, T& self, K& key) {
|
||||||
|
@ -19612,7 +19606,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_writable(std::false_type, lua_State*, T&, iterator&, stack_object) {
|
static detail::error_result set_writable(std::false_type, lua_State*, T&, iterator&, stack_object) {
|
||||||
return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
return detail::error_result(
|
||||||
|
"cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_category(std::input_iterator_tag, lua_State* L, T& self, stack_object okey, stack_object value) {
|
static detail::error_result set_category(std::input_iterator_tag, lua_State* L, T& self, stack_object okey, stack_object value) {
|
||||||
|
@ -19653,11 +19648,10 @@ namespace sol {
|
||||||
static detail::error_result set_comparative(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) {
|
static detail::error_result set_comparative(std::true_type, lua_State* L, T& self, stack_object okey, stack_object value) {
|
||||||
decltype(auto) key = okey.as<K>();
|
decltype(auto) key = okey.as<K>();
|
||||||
if (!is_writable::value) {
|
if (!is_writable::value) {
|
||||||
return detail::error_result("cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
return detail::error_result(
|
||||||
|
"cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
|
||||||
}
|
}
|
||||||
auto fx = [&](const value_type& r) -> bool {
|
auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); };
|
||||||
return key == get_key(is_associative(), r);
|
|
||||||
};
|
|
||||||
auto e = deferred_uc::end(L, self);
|
auto e = deferred_uc::end(L, self);
|
||||||
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
||||||
if (it == e) {
|
if (it == e) {
|
||||||
|
@ -19667,12 +19661,14 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_comparative(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
static detail::error_result set_comparative(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
||||||
return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key", detail::demangle<T>().data(), detail::demangle<K>().data());
|
return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key",
|
||||||
|
detail::demangle<T>().data(),
|
||||||
|
detail::demangle<K>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) {
|
static detail::error_result set_associative_insert(std::true_type, lua_State*, T& self, Iter& it, K& key, stack_object value) {
|
||||||
if constexpr(meta::has_insert<T>::value) {
|
if constexpr (meta::has_insert<T>::value) {
|
||||||
self.insert(it, value_type(key, value.as<V>()));
|
self.insert(it, value_type(key, value.as<V>()));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -19680,13 +19676,14 @@ namespace sol {
|
||||||
(void)self;
|
(void)self;
|
||||||
(void)it;
|
(void)it;
|
||||||
(void)key;
|
(void)key;
|
||||||
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
return detail::error_result(
|
||||||
|
"cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) {
|
static detail::error_result set_associative_insert(std::false_type, lua_State*, T& self, Iter& it, K& key, stack_object) {
|
||||||
if constexpr(has_insert<T>::value) {
|
if constexpr (meta::has_insert<T>::value) {
|
||||||
self.insert(it, key);
|
self.insert(it, key);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -19694,7 +19691,8 @@ namespace sol {
|
||||||
(void)self;
|
(void)self;
|
||||||
(void)it;
|
(void)it;
|
||||||
(void)key;
|
(void)key;
|
||||||
return detail::error_result("cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
|
return detail::error_result(
|
||||||
|
"cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19785,7 +19783,8 @@ namespace sol {
|
||||||
|
|
||||||
template <bool = false>
|
template <bool = false>
|
||||||
static detail::error_result find_comparative(std::false_type, lua_State*, T&) {
|
static detail::error_result find_comparative(std::false_type, lua_State*, T&) {
|
||||||
return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable", detail::demangle<T>().c_str());
|
return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable",
|
||||||
|
detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool idx_of = false>
|
template <bool idx_of = false>
|
||||||
|
@ -19877,7 +19876,7 @@ namespace sol {
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) {
|
static detail::error_result add_associative(std::true_type, lua_State* L, T& self, stack_object key, Iter& pos) {
|
||||||
if constexpr(meta::has_insert<T>::value) {
|
if constexpr (meta::has_insert<T>::value) {
|
||||||
self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L, 3)));
|
self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L, 3)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -19886,7 +19885,8 @@ namespace sol {
|
||||||
(void)self;
|
(void)self;
|
||||||
(void)key;
|
(void)key;
|
||||||
(void)pos;
|
(void)pos;
|
||||||
return detail::error_result("cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
return detail::error_result(
|
||||||
|
"cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19953,7 +19953,8 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result insert_after_has(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
static detail::error_result insert_after_has(std::false_type, lua_State*, T&, stack_object, stack_object) {
|
||||||
return detail::error_result("cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().data());
|
return detail::error_result(
|
||||||
|
"cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) {
|
static detail::error_result insert_has(std::true_type, lua_State* L, T& self, stack_object key, stack_object value) {
|
||||||
|
@ -19982,9 +19983,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result erase_integral(std::false_type, lua_State* L, T& self, const K& key) {
|
static detail::error_result erase_integral(std::false_type, lua_State* L, T& self, const K& key) {
|
||||||
auto fx = [&](const value_type& r) -> bool {
|
auto fx = [&](const value_type& r) -> bool { return key == r; };
|
||||||
return key == r;
|
|
||||||
};
|
|
||||||
auto e = deferred_uc::end(L, self);
|
auto e = deferred_uc::end(L, self);
|
||||||
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
auto it = std::find_if(deferred_uc::begin(L, self), e, std::ref(fx));
|
||||||
if (it == e) {
|
if (it == e) {
|
||||||
|
@ -20069,7 +20068,7 @@ namespace sol {
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result get_start(lua_State* L, T& self, K& key) {
|
static detail::error_result get_start(lua_State* L, T& self, K& key) {
|
||||||
return get_associative_find(std::integral_constant<bool, is_associative::value && has_find<T>::value>(), L, self, key);
|
return get_associative_find(std::integral_constant < bool, is_associative::value&& has_find<T>::value > (), L, self, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) {
|
static detail::error_result set_start(lua_State* L, T& self, stack_object key, stack_object value) {
|
||||||
|
@ -20296,8 +20295,7 @@ namespace sol {
|
||||||
T& source;
|
T& source;
|
||||||
iterator it;
|
iterator it;
|
||||||
|
|
||||||
iter(T& source, iterator it)
|
iter(T& source, iterator it) : source(source), it(std::move(it)) {
|
||||||
: source(source), it(std::move(it)) {
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20305,10 +20303,13 @@ namespace sol {
|
||||||
auto p = stack::unqualified_check_get<T*>(L, 1);
|
auto p = stack::unqualified_check_get<T*>(L, 1);
|
||||||
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
|
||||||
if (!p) {
|
if (!p) {
|
||||||
luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
|
luaL_error(L,
|
||||||
|
"sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
|
||||||
|
detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
if (p.value() == nullptr) {
|
if (p.value() == nullptr) {
|
||||||
luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
luaL_error(
|
||||||
|
L, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
|
||||||
}
|
}
|
||||||
#endif // Safe getting with error
|
#endif // Safe getting with error
|
||||||
return *p.value();
|
return *p.value();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user