From c49428c93b741dd4b976f78ef3857532220bbd1a Mon Sep 17 00:00:00 2001 From: Daniel Wallin Date: Fri, 16 Dec 2005 17:51:47 +0000 Subject: [PATCH] Object operators are now using SFINAE. --- luabind/object.hpp | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/luabind/object.hpp b/luabind/object.hpp index 7abe0ff..1c8596c 100644 --- a/luabind/object.hpp +++ b/luabind/object.hpp @@ -42,6 +42,7 @@ #include #include +#include namespace luabind { @@ -92,6 +93,25 @@ namespace detail namespace adl { + namespace mpl = boost::mpl; + + template + struct enable_binary +# ifndef BOOST_NO_SFINAE + : boost::enable_if< + mpl::or_< + is_value_wrapper + , is_value_wrapper + > + , R + > + {}; +# else + { + typedef R type; + }; +# endif + template lua_State* binary_interpreter(T const& x, U const&, boost::mpl::true_, V) { @@ -117,7 +137,8 @@ namespace adl #define LUABIND_BINARY_OP_DEF(op, fn) \ template \ - bool operator op(LHS const& lhs, RHS const& rhs) \ + typename enable_binary::type \ + operator op(LHS const& lhs, RHS const& rhs) \ { \ lua_State* L = binary_interpreter(lhs, rhs); \ \ @@ -137,25 +158,29 @@ namespace adl #undef LUABIND_BINARY_OP_DEF template - bool operator>(LHS const& lhs, RHS const& rhs) + typename enable_binary::type + operator>(LHS const& lhs, RHS const& rhs) { return !(lhs < rhs || lhs == rhs); } template - bool operator<=(LHS const& lhs, RHS const& rhs) + typename enable_binary::type + operator<=(LHS const& lhs, RHS const& rhs) { return lhs < rhs || lhs == rhs; } template - bool operator>=(LHS const& lhs, RHS const& rhs) + typename enable_binary::type + operator>=(LHS const& lhs, RHS const& rhs) { return !(lhs < rhs); } template - bool operator!=(LHS const& lhs, RHS const& rhs) + typename enable_binary::type + operator!=(LHS const& lhs, RHS const& rhs) { return !(lhs < rhs); } -- 2.11.4.GIT