Title
Preferring conversion to std::initializer_list
Status
cd2
Section
12.2.4.3 [over.ics.rank]
Submitter
Jason Merrill

Created on 2008-07-02.00:00:00 last changed 143 months ago

Messages

Date: 2009-07-15.00:00:00

[Voted into WP at July, 2009 meeting.]

Date: 2009-03-15.00:00:00

Proposed resolution (March, 2009):

Add a new top-level bullet at the end of the current list in 12.2.4.3 [over.ics.rank] paragraph 3:

  • List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if L1 converts to std::initializer_list<X> for some X and L2 does not.
Date: 2008-07-02.00:00:00

We need another bullet in 12.2.4.3 [over.ics.rank], along the lines of:

  • List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if L1 converts to std::initializer_list<X> for some X and L2 does not.

This is necessary to make the following example work:

    #include <initializer_list>

    struct string {
      string (const char *) {}
      template <class Iter> string (Iter, Iter);
    };

    template <class T, class U>
    struct pair {
      pair (T t, U u) {}
    };

    template<class T, class U>
    struct map {
      void insert (pair<T,U>);
      void insert (std::initializer_list<pair<T,U> >) {}
    };

    int main() {
      map<string,string> m;
      m.insert({ {"this","that"}, {"me","you"} });
    }
History
Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-11-08 00:00:00adminsetstatus: dr -> wp
2009-08-03 00:00:00adminsetmessages: + msg2269
2009-08-03 00:00:00adminsetstatus: ready -> dr
2009-03-23 00:00:00adminsetmessages: + msg1893
2009-03-23 00:00:00adminsetstatus: drafting -> ready
2008-10-05 00:00:00adminsetstatus: open -> drafting
2008-07-02 00:00:00admincreate