Skip to content

Commit

Permalink
Add policies to luabind::functor template parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocaster committed Dec 13, 2015
1 parent c4e5dd2 commit beb3312
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/xrScriptEngine/Functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@

namespace luabind
{
template<typename TResult>
template <typename TResult, typename... Policies>
class functor : public adl::object
{
public:
functor() {}
functor(const adl::object &obj) : adl::object(obj) {}

template<typename... Args>
template <typename... Args>
TResult operator()(Args &&...args) const
{ return call_function<TResult>(*static_cast<const adl::object *>(this), std::forward<Args>(args)...); }
{
auto self = static_cast<const adl::object *>(this);
return call_function<TResult, policy_list<Policies...>>(*self, std::forward<Args>(args)...);
}
};

template<>
template<typename... Args>
void functor<void>::operator()(Args &&...args) const
{ call_function<void>(*static_cast<const adl::object *>(this), std::forward<Args>(args)...); }
template <>
template <typename... Args>
void functor<void, typename...>::operator()(Args &&...args) const
{
auto self = static_cast<const adl::object *>(this);
call_function<void, policy_list<Policies...>>(*self, std::forward<Args>(args)...);
}

namespace detail
{
Expand Down
3 changes: 2 additions & 1 deletion src/xrScriptEngine/script_space_forward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace adl
class object;
}

template<class T> class functor;
template <typename TResult, typename... Policies>
class functor;
template<class T, class ValueWrapper>
T object_cast(ValueWrapper const& value_wrapper);
};

0 comments on commit beb3312

Please sign in to comment.