Phoenix
Object-oriented orthogonally persistent operating system
|
00001 /* 00002 * /phoenix/include/std.h 00003 * 00004 * This file is a part of Phoenix operating system. 00005 * Copyright (c) 2011-2012, Artyom Lebedev <artyom.lebedev@gmail.com> 00006 * All rights reserved. 00007 * See COPYING file for copyright details. 00008 */ 00009 00017 #ifndef STD_H_ 00018 #define STD_H_ 00019 00021 namespace std { 00022 00024 template<class _E> 00025 class initializer_list { 00026 public: 00027 typedef _E value_type; 00028 typedef const _E& reference; 00029 typedef const _E& const_reference; 00030 typedef size_t size_type; 00031 typedef const _E* iterator; 00032 typedef const _E* const_iterator; 00033 00034 private: 00035 iterator _M_array; 00036 size_type _M_len; 00037 00038 /* The compiler can call a private constructor. */ 00039 constexpr initializer_list(const_iterator __a, size_type __l) : 00040 _M_array(__a), _M_len(__l) 00041 { 00042 } 00043 00044 public: 00045 constexpr initializer_list() : 00046 _M_array(0), _M_len(0) 00047 { 00048 } 00049 00050 /* Number of elements. */ 00051 constexpr 00052 size_type size() 00053 { 00054 return _M_len; 00055 } 00056 00057 /* First element. */ 00058 constexpr 00059 const_iterator begin() 00060 { 00061 return _M_array; 00062 } 00063 00064 /* One past the last element. */ 00065 constexpr 00066 const_iterator end() 00067 { 00068 return begin() + size(); 00069 } 00070 }; 00071 00075 template<class _Tp> 00076 constexpr const _Tp* 00077 begin(initializer_list<_Tp> __ils) 00078 { 00079 return __ils.begin(); 00080 } 00081 00086 template<class _Tp> 00087 constexpr const _Tp* 00088 end(initializer_list<_Tp> __ils) 00089 { 00090 return __ils.end(); 00091 } 00092 00093 } /* namespace std */ 00094 00095 #endif /* STD_H_ */