VC++ actually doesn't respect array reference return types through decltype. Kek. It's obscure, but... goodness, how does GCC and Clang get these things right consistently while VC++ keeps fumbling at it?

This commit is contained in:
ThePhD 2018-03-18 23:41:03 -04:00
parent d14345f016
commit f50d8e271f
4 changed files with 34 additions and 22 deletions

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 2018-03-17 13:09:07.758298 UTC // Generated 2018-03-19 03:40:57.438213 UTC
// This header was generated with sol v2.19.5 (revision 947945d) // This header was generated with sol v2.19.5 (revision d14345f)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -927,21 +927,22 @@ namespace meta {
template <typename R, typename T> template <typename R, typename T>
struct callable_traits<R(T::*), true> { struct callable_traits<R(T::*), true> {
typedef R Arg; typedef std::conditional_t<std::is_array<R>::value, std::add_lvalue_reference_t<T>, R> return_type;
typedef return_type Arg;
typedef T object_type; typedef T object_type;
typedef std::conditional_t<std::is_array<R>::value, std::add_lvalue_reference_t<T>, R> return_type;
using signature_type = R(T::*); using signature_type = R(T::*);
static const bool is_noexcept = false; static const bool is_noexcept = false;
static const bool is_member_function = false; static const bool is_member_function = false;
static const std::size_t arity = 1; static const std::size_t arity = 1;
static const std::size_t free_arity = 2; static const std::size_t free_arity = 2;
typedef std::tuple<Arg> args_tuple; typedef std::tuple<Arg> args_tuple;
typedef R return_type;
typedef types<Arg> args_list; typedef types<Arg> args_list;
typedef types<T, Arg> free_args_list; typedef types<T, Arg> free_args_list;
typedef meta::tuple_types<R> returns_list; typedef meta::tuple_types<return_type> returns_list;
typedef R(function_type)(T&, R); typedef return_type(function_type)(T&, return_type);
typedef R (*function_pointer_type)(T&, R); typedef return_type(*function_pointer_type)(T&, Arg);
typedef R (*free_function_pointer_type)(T&, R); typedef return_type(*free_function_pointer_type)(T&, Arg);
template <std::size_t i> template <std::size_t i>
using arg_at = void_tuple_element_t<i, args_tuple>; using arg_at = void_tuple_element_t<i, args_tuple>;
}; };
@ -11944,6 +11945,11 @@ namespace sol {
namespace sol { namespace sol {
namespace detail {
template <typename T>
using array_return_type = std::conditional_t<std::is_array<T>::value, std::add_lvalue_reference_t<T>, T>;
}
template <typename F, typename = void> template <typename F, typename = void>
struct wrapper { struct wrapper {
typedef lua_bind_traits<meta::unqualified_t<F>> traits_type; typedef lua_bind_traits<meta::unqualified_t<F>> traits_type;
@ -12007,7 +12013,7 @@ namespace sol {
typedef typename traits_type::returns_list returns_list; typedef typename traits_type::returns_list returns_list;
template <F fx> template <F fx>
static decltype(auto) invoke(object_type& mem) { static auto call(object_type& mem) -> detail::array_return_type<decltype(mem.*fx)> {
return mem.*fx; return mem.*fx;
} }
@ -12017,8 +12023,8 @@ namespace sol {
} }
template <typename Fx> template <typename Fx>
static decltype(auto) call(Fx&& fx, object_type& mem) { static auto call(Fx&& fx, object_type& mem) -> detail::array_return_type<decltype(mem.*fx)> {
return (mem.*fx); return mem.*fx;
} }
template <typename Fx, typename Arg, typename... Args> template <typename Fx, typename Arg, typename... Args>

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 2018-03-17 13:09:07.970531 UTC // Generated 2018-03-19 03:40:57.670830 UTC
// This header was generated with sol v2.19.5 (revision 947945d) // This header was generated with sol v2.19.5 (revision d14345f)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -507,21 +507,22 @@ namespace meta {
template <typename R, typename T> template <typename R, typename T>
struct callable_traits<R(T::*), true> { struct callable_traits<R(T::*), true> {
typedef R Arg; typedef std::conditional_t<std::is_array<R>::value, std::add_lvalue_reference_t<T>, R> return_type;
typedef return_type Arg;
typedef T object_type; typedef T object_type;
typedef std::conditional_t<std::is_array<R>::value, std::add_lvalue_reference_t<T>, R> return_type;
using signature_type = R(T::*); using signature_type = R(T::*);
static const bool is_noexcept = false; static const bool is_noexcept = false;
static const bool is_member_function = false; static const bool is_member_function = false;
static const std::size_t arity = 1; static const std::size_t arity = 1;
static const std::size_t free_arity = 2; static const std::size_t free_arity = 2;
typedef std::tuple<Arg> args_tuple; typedef std::tuple<Arg> args_tuple;
typedef R return_type;
typedef types<Arg> args_list; typedef types<Arg> args_list;
typedef types<T, Arg> free_args_list; typedef types<T, Arg> free_args_list;
typedef meta::tuple_types<R> returns_list; typedef meta::tuple_types<return_type> returns_list;
typedef R(function_type)(T&, R); typedef return_type(function_type)(T&, return_type);
typedef R (*function_pointer_type)(T&, R); typedef return_type(*function_pointer_type)(T&, Arg);
typedef R (*free_function_pointer_type)(T&, R); typedef return_type(*free_function_pointer_type)(T&, Arg);
template <std::size_t i> template <std::size_t i>
using arg_at = void_tuple_element_t<i, args_tuple>; using arg_at = void_tuple_element_t<i, args_tuple>;
}; };

View File

@ -28,6 +28,11 @@
namespace sol { namespace sol {
namespace detail {
template <typename T>
using array_return_type = std::conditional_t<std::is_array<T>::value, std::add_lvalue_reference_t<T>, T>;
}
template <typename F, typename = void> template <typename F, typename = void>
struct wrapper { struct wrapper {
typedef lua_bind_traits<meta::unqualified_t<F>> traits_type; typedef lua_bind_traits<meta::unqualified_t<F>> traits_type;
@ -91,7 +96,7 @@ namespace sol {
typedef typename traits_type::returns_list returns_list; typedef typename traits_type::returns_list returns_list;
template <F fx> template <F fx>
static decltype(auto) invoke(object_type& mem) { static auto call(object_type& mem) -> detail::array_return_type<decltype(mem.*fx)> {
return mem.*fx; return mem.*fx;
} }
@ -101,8 +106,8 @@ namespace sol {
} }
template <typename Fx> template <typename Fx>
static decltype(auto) call(Fx&& fx, object_type& mem) { static auto call(Fx&& fx, object_type& mem) -> detail::array_return_type<decltype(mem.*fx)> {
return (mem.*fx); return mem.*fx;
} }
template <typename Fx, typename Arg, typename... Args> template <typename Fx, typename Arg, typename... Args>