#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)
Change History (3)
by , 10 years ago
Attachment: | terminal_test.cpp added |
---|
comment:1 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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 , 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_ { };
Code sample that illustrates the problem