This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

1071. is_bind_expression should derive from integral_constant<bool>

Section: 22.10.15.2 [func.bind.isbind] Status: C++11 Submitter: Alisdair Meredith Opened: 2009-03-19 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [func.bind.isbind].

View all issues with C++11 status.

Discussion:

Class template is_bind_expression 22.10.15.2 [func.bind.isbind]:

namespace std {
  template<class T> struct is_bind_expression {
    static const bool value = see below;
  };
}

is_bind_expression should derive from std::integral_constant<bool> like other similar trait types.

[ Daniel adds: ]

We need the same thing for the trait is_placeholder as well.

[ 2009-03-22 Daniel provided wording. ]

[ Batavia (2009-05): ]

We recommend this be deferred until after the next Committee Draft is issued.

Move to Open.

[ 2009-05-31 Peter adds: ]

I am opposed to the proposed resolution and to the premise of the issue in general. The traits's default definitions should NOT derive from integral_constant, because this is harmful, as it misleads people into thinking that is_bind_expression<E> always derives from integral_constant, whereas it may not.

is_bind_expression and is_placeholder allow user specializations, and in fact, this is their primary purpose. Such user specializations may not derive from integral_constant, and the places where is_bind_expression and is_placeholder are used intentionally do not require such derivation.

The long-term approach here is to switch to BindExpression<E> and Placeholder<P> explicit concepts, of course, but until that happens, I say leave them alone.

[ 2009-10 post-Santa Cruz: ]

Move to Tentatively Ready. We are comfortable with requiring user specializations to derive from integral_constant.

Proposed resolution:

  1. In 22.10.15.2 [func.bind.isbind] change as indicated:

    namespace std {
     template<class T> struct is_bind_expression : integral_constant<bool, see below> { };{
       static const bool value = see below;
     };
    }
    
  2. In 22.10.15.2 [func.bind.isbind]/2 change as indicated:

    static const bool value;
    

    -2- true if T is a type returned from bind, false otherwise. If T is a type returned from bind, is_bind_expression<T> shall be publicly derived from integral_constant<bool, true>, otherwise it shall be publicly derived from integral_constant<bool, false>.

  3. In 22.10.15.3 [func.bind.isplace] change as indicated:

    namespace std {
     template<class T> struct is_placeholder : integral_constant<int, see below> { };{
       static const int value = see below;
     };
    }
    
  4. In 22.10.15.3 [func.bind.isplace]/2 change as indicated:

    static const int value;
    

    -2- value is J if T is the type of std::placeholders::_J, 0 otherwise. If T is the type of std::placeholders::_J, is_placeholder<T> shall be publicly derived from integral_constant<int, J> otherwise it shall be publicly derived from integral_constant<int, 0>.