[Boost-bugs] [Boost C++ Libraries] #7730: Generic specializations of is_nullary for custom terminals are not possible

Subject: [Boost-bugs] [Boost C++ Libraries] #7730: Generic specializations of is_nullary for custom terminals are not possible
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-24 12:34:14


#7730: Generic specializations of is_nullary for custom terminals are not possible
------------------------------+---------------------------------------------
 Reporter: andysem | Owner: theller
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: phoenix
  Version: Boost 1.52.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 The is_nullary trait is specialized for all custom_terminal<T> to be true
 (see phoenix/code/is_nullary.hpp).

 {{{
 template <typename T>
 struct is_nullary<custom_terminal<T> >
     : mpl::true_
 {};
 }}}

 This is not true with regard to multiple terminals I define in Boost.Log.
 This forces me to specialize is_nullary for all my custom terminals, and I
 cannot provide a single blanket specialization for all my terminals.

 The is_nullary trait has a second template parameter which is intended to
 be used exactly for this purpose. A nested tag void typedef can be used to
 match the trait for a set of types. I could create the following
 specialization:

 {{{
 template <typename T>
 struct is_nullary<custom_terminal<T>, typename T::_is_my_terminal >
     : mpl::false_
 {};
 }}}

 However this extension mechanism does not work because the two
 specializations are considered equally specialized and the compiler
 reports ambiguity.

 I suggest to limit the first specialization to only match the default
 custom terminals, e.g.:

 {{{
 template <typename T>
 struct is_nullary<custom_terminal<T>, typename
 custom_terminal<T>::_is_default_custom_terminal >
     : mpl::true_
 {};
 }}}

 Where typedef void _is_default_custom_terminal will be added to the
 generic custom_terminal template.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7730>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:11 UTC