From 20a0b0809f67d42923ce9115a2df62c862495bb8 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 31 Mar 2019 14:38:48 -0400 Subject: [PATCH] decltype(auto), let's hope it does the right thing... --- include/sol/usertype_container.hpp | 9 +++++---- single/include/sol/forward.hpp | 4 ++-- single/include/sol/sol.hpp | 13 +++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/sol/usertype_container.hpp b/include/sol/usertype_container.hpp index f00ee3e5..736f6ac0 100644 --- a/include/sol/usertype_container.hpp +++ b/include/sol/usertype_container.hpp @@ -564,7 +564,7 @@ namespace sol { } static detail::error_result get_associative(std::true_type, lua_State* L, iterator& it) { - auto& v = *it; + decltype(auto) v = *it; return stack::stack_detail::push_reference(L, detail::deref_non_pointer(v.second)); } @@ -627,13 +627,13 @@ namespace sol { } static detail::error_result set_associative(std::true_type, iterator& it, stack_object value) { - auto& v = *it; + decltype(auto) v = *it; v.second = value.as(); return {}; } static detail::error_result set_associative(std::false_type, iterator& it, stack_object value) { - auto& v = *it; + decltype(auto) v = *it; v = value.as(); return {}; } @@ -1298,7 +1298,8 @@ namespace sol { decltype(auto) value = stack::unqualified_get(L, 2); std::size_t N = std::extent::value; for (std::size_t idx = 0; idx < N; ++idx) { - const auto& v = self[idx]; + using v_t = std::add_const_t; + v_t v = self[idx]; if (v == value) { idx -= deferred_uc::index_adjustment(L, self); return stack::push(L, idx); diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 19af118a..cdb940ea 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2019-03-31 03:30:36.689278 UTC -// This header was generated with sol v3.0.1-beta2 (revision 6017f63) +// Generated 2019-03-31 18:38:29.717261 UTC +// This header was generated with sol v3.0.1-beta2 (revision 26cbadc) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 0014dd69..06c839ee 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2019-03-31 03:30:35.378291 UTC -// This header was generated with sol v3.0.1-beta2 (revision 6017f63) +// Generated 2019-03-31 18:38:28.701189 UTC +// This header was generated with sol v3.0.1-beta2 (revision 26cbadc) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -19059,7 +19059,7 @@ namespace sol { } static detail::error_result get_associative(std::true_type, lua_State* L, iterator& it) { - auto& v = *it; + decltype(auto) v = *it; return stack::stack_detail::push_reference(L, detail::deref_non_pointer(v.second)); } @@ -19122,13 +19122,13 @@ namespace sol { } static detail::error_result set_associative(std::true_type, iterator& it, stack_object value) { - auto& v = *it; + decltype(auto) v = *it; v.second = value.as(); return {}; } static detail::error_result set_associative(std::false_type, iterator& it, stack_object value) { - auto& v = *it; + decltype(auto) v = *it; v = value.as(); return {}; } @@ -19793,7 +19793,8 @@ namespace sol { decltype(auto) value = stack::unqualified_get(L, 2); std::size_t N = std::extent::value; for (std::size_t idx = 0; idx < N; ++idx) { - const auto& v = self[idx]; + using v_t = std::add_const_t; + v_t v = self[idx]; if (v == value) { idx -= deferred_uc::index_adjustment(L, self); return stack::push(L, idx);