Re: Phoenix pointer to member operator not working when compiling with gcc and -std=c++0x
Thomas Heller <thom.heller <at> googlemail.com>
2012-02-06 11:53:31 GMT
On Mon, Feb 6, 2012 at 3:30 AM, Seth Heeren <bugs <at> sehe.nl> wrote:
> On 02/05/2012 06:50 PM, Öyvind Strand wrote:
>
> Hi,
>
> A phoenix expression using the pointer to member operator pointing to a
> member function doesn't compile. This occurs only
> when compiling with -std=c++0x AND taking the address of the object inside
> the phoenix expression. There's no problem
> when pointing to a data member or passing something that is already a
> pointer to the phoenix expression or compiling without -std=c++0x.
>
>
> That looks like an awesome selfcontained test. I'm not exactly sure I get
> the inent of the comma-operators ('lazy' statement separation?) and
>
> ((&arg1)->*&type::func)() , //Doesn't compile
>
> apparently redundant function call application here:
> ((&arg1)->*&type::func)(); I'm assuming that means 'partial function
> application' (in this case, applying none of 1 existing parameters).
>
> Regardless, the following compiles for me on boost 1_48 with gcc 4.6.1 with
> or without -std=c++0x:
>
> ((&arg1)->*(&type::func)) ( obj); //Compiles
> ((&arg1)->*(&type::func))()( obj); //Compiles - breaks with -std=c++0x
> ((&arg1)->*(&type::data)) ( obj); //Compiles
>
> ((&arg1)->*(&type::func)) (&obj); //Compiles
> (( arg1)->*(&type::func))()(&obj); //Compiles - breaks with phoenixV2
> (( arg1)->*(&type::data)) (&obj); //Compiles - breaks with phoenixV2
>
> // compound phoenix bodies
> (((&arg1)->*(&type::func)), //Compiles
> ((&arg1)->*(&type::func))(), //Compiles - breaks with -std=c++0x
> ((&arg1)->*(&type::data)))( obj); //Compiles
>
> (((&arg1)->*(&type::func)), //Compiles
> (( arg1)->*(&type::func))(), //Compiles - breaks with phoenixV2
> (( arg1)->*(&type::data)))(&obj); //Compiles - breaks with phoenixV2
>
> See also attached test.cpp
>
> Is there any more information that can be gleaned from this?
Let me try to explain (only speaking for Phoenix V3):
1) Phoenix V3 is currently broken when using with decltype as the result_of
implementation: https://svn.boost.org/trac/boost/ticket/5687
Note: BOOST_RESULT_OF_USE_DECLTYPE isn't turned on by default
in C++ 11 mode.
2) ((&arg1)->*(&type::func)) returns something which is not a phoenix actor.
It returns a callable which is, when called turned into the proper member
function pointer phoenix actor. This should probably be checked in the
phoenix grammar. (Side note: it doesn't make any sense to take the
pointer again, in the case where the 1st argument is already a pointer).
This is of course different if we want a pointer to a member
variable, which
doesn't need the function application.
3) I can confirm that ((&arg1)->*(&type::func))()( obj); doesn't
compile ... this is
a bug! (The wrong operator->* is selected, needs investigation)
4) As a workaround, I can offer this:
bind(&type::func, &arg1)(obj);
bind(&type::func, arg1)(obj);
bind(&type::func, arg1)(&obj);
Regards,
Thomas
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general