#pragma once

#include "luaerror.h"
#include "luatype.h"

namespace Luax
{
	struct LuaReturn
	{
		lua_State* l = nullptr;
		int index = 1;

		template<typename T> operator T() const
		{
			if (l)
			{
				if (luax_argcheck<T>(l, index))
				{
					return GetFromLuaType<T>(l, index);
				}
				else
				{
					Error::instance().handle(l);
				}
			}
			return T();
		}
	};

}