initializer_list (1115B)
1 // -*- c++ -*- 2 #pragma once 3 4 #include <cstddef> 5 6 7 // orig msvc header stores begin/end ptrs 8 // https://timsong-cpp.github.io/cppwp/n4659/support.initlist 9 namespace std 10 { 11 12 template <typename E> 13 class initializer_list 14 { 15 public: 16 using value_type = E; 17 using reference = const E&; 18 using const_reference = const E&; 19 using size_type = size_t; 20 21 using iterator = const E*; 22 using const_iterator = const E*; 23 24 constexpr initializer_list() noexcept = default; 25 26 constexpr size_t size() const noexcept { return last-first; }// number of elements 27 constexpr const E* begin() const noexcept { return first; } // first element 28 constexpr const E* end() const noexcept { return last; } // one past the last element 29 30 private: 31 const iterator first = nullptr, last = nullptr; 32 }; 33 34 // [support.initlist.range], initializer list range access 35 template <typename E> 36 constexpr const E* begin(initializer_list<E> il) noexcept { return il.begin(); } 37 template <typename E> 38 constexpr const E* end(initializer_list<E> il) noexcept { return il.end(); } 39 }