incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject initializer_list support in gcc 4.4
Date Tue, 29 Jul 2008 00:50:26 GMT
FYI: the head of gcc trunk (future 4.4) implements support for
initializer lists:

$ g++ -dumpversion && g++ -std=c++0x t.cpp && ./a.out
4.4.0
S::S(std::initializer_list<int>): size = 0: { }
S::S(std::initializer_list<int>): size = 4: { 1 2 3 4 }
tmp$ cat t.cpp && g++ -dumpversion && g++ -std=c++0x t.cpp && ./a.out
#include <initializer_list>
#include <stdio.h>

struct S {
     S (std::initializer_list<int> x) {
         printf ("%s: size = %zu: { ", __PRETTY_FUNCTION__, x.size ());
         for (const int *p = x.begin (); p != x.end (); ++p)
             printf ("%d ", *p);
         puts ("}");
     }
};

int main (int argc, char**) {
     S s1 { };
     S s2 ({1, 2, 3, 4});
}
4.4.0
S::S(std::initializer_list<int>): size = 0: { }
S::S(std::initializer_list<int>): size = 4: { 1 2 3 4 }

Mime
View raw message