Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#7300 closed Bugs (fixed)

Custom terminals are always nullary

Reported by: Andrey Semashev Owned by: Thomas Heller
Milestone: To Be Determined Component: phoenix
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

The is_nullary trait is specialized for custom_terminal<T> and returns true. There is no way to specialize is_nullary for a template custom terminal so that it returns false.

The attached code sample illustrates the problem, I could not make it compile with GCC 4.6. More details available in this thread.

Attachments (1)

terminal_test.cpp (4.0 KB ) - added by Andrey Semashev 10 years ago.
Code sample that illustrates the problem

Download all attachments as: .zip

Change History (3)

by Andrey Semashev, 10 years ago

Attachment: terminal_test.cpp added

Code sample that illustrates the problem

comment:1 by Thomas Heller, 10 years ago

Resolution: fixed
Status: newclosed

Sorry for the delay ... looks like there is something wrong with my mail client ... I replied to your message to the mailing list already ...

The solution is here:

namespace my { template <typename> class output_terminal; }

namespace boost { namespace phoenix { namespace result_of {

    template< typename T >
    struct is_nullary< custom_terminal< my::output_terminal<T> > > :
        public mpl::false_
    {};

}}}

Put this at the beginning of your file and it compiles and runs. The is_nullary specialization needs to be wrapped inside another custom_terminal template in order to disambiguate from other rules.

comment:2 by Andrey Semashev, 10 years ago

Thanks for the answer, it worked. Could the specialization in Boost.Phoenix be made more specific (for example, by using the nested void type technique) so that it is possible to create more generic specializations in user's code, like this:

template< typename T >
struct is_nullary< custom_terminal< T >, typename T::_is_my_terminal > :
    public mpl::false_
{
};
Note: See TracTickets for help on using tickets.