Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/warn/Winit-list2.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line source
// { dg-do compile { target c++11 } } #include <initializer_list> extern "C" int printf (const char *, ...); using size_t = decltype(sizeof(0)); template <typename T> class ArrayRef { public: using size_type = size_t; private: /// The start of the array, in an external buffer. const T *Data = nullptr; /// The number of elements. size_type Length = 0; public: /// Construct an ArrayRef from a std::initializer_list. /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec) : Data(Vec.begin() == Vec.end() ? (T *)nullptr : Vec.begin()), // { dg-warning initializer_list } Length(Vec.size()) {} const T &operator[](size_t Index) const { return Data[Index]; } }; int main() { const ArrayRef<int> Foo = {42}; printf ("Foo %d\n", Foo[0]); }