Skip to content

Commit

Permalink
fix lua->C++ pass of const references to arithmetic types (make a copy)
Browse files Browse the repository at this point in the history
  • Loading branch information
pisto committed Mar 30, 2014
1 parent b8f1b0c commit 0865f1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/LuaBridge/LuaBridge.h
Expand Up @@ -41,6 +41,7 @@

#include <lua.hpp>
#include <new>
#include <type_traits>

#define LUABRIDGE_MAJOR_VERSION 2
#define LUABRIDGE_MINOR_VERSION 0
Expand Down
5 changes: 3 additions & 2 deletions include/LuaBridge/detail/TypeList.h
Expand Up @@ -123,10 +123,11 @@ struct TypeListValues <TypeList <Head&, Tail> >
template <typename Head, typename Tail>
struct TypeListValues <TypeList <Head const&, Tail> >
{
const Head& hd;
using HeadStorage = typename std::conditional<std::is_arithmetic<Head>::value, Head, Head const&>::type;
HeadStorage hd;
TypeListValues <Tail> tl;

TypeListValues (Head const& hd_, const TypeListValues <Tail>& tl_)
TypeListValues (HeadStorage hd_, const TypeListValues <Tail>& tl_)
: hd (hd_), tl (tl_)
{
}
Expand Down

0 comments on commit 0865f1c

Please sign in to comment.