Re: Member pointers in 0.8.1

Daniel Wallin <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Ilia Trendafilov wrote:
> James Porter wrote:
>> Your code works for me in Luabind 0.8.1 / Lua 5.1.4 / MSVC8 SP1 with no
>> problems whatsoever. Is your version of Lua up to date, and did you
>> compile Luabind via bjam?

Really? That's weird. It fails for me on GCC 4.3.2 as well.

> Since you can run the code, it seems that I'm doing something wrong,
> but I don't have a clue what it might be. Not sure if that's relevant,
> boost version is 1.37 on Windows and 1.38 on Linux, built by bjam on
> both OSes.

Can you try this patch, it should solve the problem:

diff --git a/luabind/class.hpp b/luabind/class.hpp
index a7dddf3..f982c23 100644
--- a/luabind/class.hpp
+++ b/luabind/class.hpp
@@ -858,6 +858,15 @@ namespace luabind
             >
         {};

+        template <class T>
+        struct reference_arg
+          : mpl::if_<
+                mpl::or_<boost::is_pointer<T>, is_primitive<T> >
+              , T
+              , typename boost::add_reference<T const>::type
+            >
+        {};
+
         template <class T, class Policies>
         struct inject_dependency_policy
           : mpl::if_<
@@ -934,7 +943,8 @@ namespace luabind
                 return make_function(
                     L
                   , access_member_ptr<T, D>(mem_ptr)
-                  , mpl::vector3<void, Class&, D const&>()
+                  , mpl::vector3<
+                        void, Class&, typename reference_arg<D>::type>()
                   , set_policies
                 );
             }


-- 
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.