// Copyright satoren // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #pragma once #include "kaguya/config.hpp" #include "kaguya/traits.hpp" namespace kaguya { #if KAGUYA_USE_CPP11 namespace detail { template struct index_tuple {}; template , bool flag = first >= last> struct index_range { using type = result; }; template struct index_range, false> : index_range > {}; template int push_tuple(lua_State *l, index_tuple, std::tuple &&v) { return util::push_args(l, std::get(v)...); } } /// @ingroup lua_type_traits /// @brief lua_type_traits for std::tuple or boost::tuple template struct lua_type_traits > { static int push(lua_State *l, std::tuple &&v) { typename detail::index_range<0, sizeof...(Args)>::type index; return detail::push_tuple(l, index, std::forward >(v)); } }; #else #define KAGUYA_PP_GET_DATA(N) standard::get(v) #define KAGUYA_PUSH_TUPLE_DEF(N) \ template \ struct lua_type_traits > { \ static int \ push(lua_State *l, \ const standard::tuple &v) { \ return util::push_args(l, KAGUYA_PP_REPEAT_ARG(N, KAGUYA_PP_GET_DATA)); \ } \ }; KAGUYA_PP_REPEAT_DEF(KAGUYA_FUNCTION_MAX_TUPLE_SIZE, KAGUYA_PUSH_TUPLE_DEF) #undef KAGUYA_PP_GET_DATA #undef KAGUYA_PUSH_TUPLE_DEF #endif }