Skip to content

Commit

Permalink
Fixed compilation problems with gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Mar 1, 2014
1 parent ee75dd8 commit 84a4d05
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions include/LuaContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2628,28 +2628,31 @@ struct LuaContext::Reader<boost::variant<TTypes...>>
private:
// class doing operations for a range of types from TIterBegin to TIterEnd
template<typename TIterBegin, typename TIterEnd, typename = void>
struct VariantReader {
struct VariantReader
{
using SubReader = Reader<typename std::decay<typename boost::mpl::deref<TIterBegin>::type>::type>;

static auto readSafe(const LuaContext& ctxt, int index)
-> ReturnType
{
auto val = Reader<typename std::decay<typename boost::mpl::deref<TIterBegin>::type>::type>::testRead(ctxt, index);
if (val.is_initialized())
return ReturnType{std::move(val.get())};
// note: using SubReader::testRead triggers a compilation error when used with a reference
if (SubReader::test(ctxt, index))
return ReturnType{SubReader::read(ctxt, index)};
return VariantReader<typename boost::mpl::next<TIterBegin>::type, TIterEnd>::readSafe(ctxt, index);
}

static auto testRead(const LuaContext& ctxt, int index)
-> boost::optional<ReturnType>
{
auto val = Reader<typename std::decay<typename boost::mpl::deref<TIterBegin>::type>::type>::testRead(ctxt, index);
if (val.is_initialized())
return ReturnType{std::move(val.get())};
// note: using SubReader::testRead triggers a compilation error when used with a reference
if (SubReader::test(ctxt, index))
return ReturnType{SubReader::read(ctxt, index)};
return VariantReader<typename boost::mpl::next<TIterBegin>::type, TIterEnd>::testRead(ctxt, index);
}

static bool test(const LuaContext& ctxt, int index)
{
if (Reader<typename std::decay<typename boost::mpl::deref<TIterBegin>::type>::type>::test(ctxt, index))
if (SubReader::test(ctxt, index))
return true;
return VariantReader<typename boost::mpl::next<TIterBegin>::type, TIterEnd>::test(ctxt, index);
}
Expand Down

0 comments on commit 84a4d05

Please sign in to comment.