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

2488. Placeholders should be allowed and encouraged to be constexpr

Section: 22.10.15.5 [func.bind.place] Status: C++17 Submitter: Stephan T. Lavavej Opened: 2015-03-27 Last modified: 2017-07-30

Priority: 2

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

View all issues with C++17 status.

Discussion:

piecewise_construct (22.3.5 [pair.piecewise]), allocator_arg (20.2.7 [allocator.tag]), and adopt_lock/defer_lock/try_to_lock (33.6.5 [thread.lock]) are all required to be constexpr with internal linkage. bind()'s placeholders should be allowed to follow this modern practice, for increased consistency and reduced implementer headaches (header-only is easier than separately-compiled).

[2015-05-07 Lenexa: Move to Immediate]

STL: I'd like this one immediate.

Jonathan: I want to think about forcing constexpr, but the current issue, I have no objections. I'd say ready, but I won't object to immediate if STL wants it.

Marshall: You should report in Kona how it worked out.

STL: We went around a bit on the reflector about how to phrase the encouragement.

Jonathan: I think the shall may be not quite right.

Marshall: I see, you can change your implementation, but you don't.

Jonathan: There's precedent for the shall, but it's wrong, see editorial issue 493.

STL: I would prefer not to ask Daniel to reword, and 493 can fix it later.

Marshall: I remove my objection to immediate because it doesn't force implementations to change.

Marshall: Any other discussion?

Marshall: Immediate vote: 6. Opposed, 0. Abstain, 1.

Proposed resolution:

This wording is relative to N4296.

  1. Change 22.10 [function.objects] p2 "Header <functional> synopsis" as depicted:

    namespace placeholders {
      // M is the implementation-defined number of placeholders
      see belowextern unspecified _1;
      see belowextern unspecified _2;
      ...
      see belowextern unspecified _M;
    }
    
  2. Change 22.10.15.5 [func.bind.place] p2 as depicted:

    namespace std::placeholders {
      // M is the implementation-defined number of placeholders
      see belowextern unspecified _1;
      see belowextern unspecified _2;
                 .
                 .
                 .
      see belowextern unspecified _M;
    }
    

    -1- All placeholder types shall be DefaultConstructible and CopyConstructible, and their default constructors and copy/move constructors shall not throw exceptions. It is implementation-defined whether placeholder types are CopyAssignable. CopyAssignable placeholders' copy assignment operators shall not throw exceptions.

    -?- Placeholders should be defined as:

    constexpr unspecified _1{};
    

    If they are not, they shall be declared as:

    extern unspecified _1;