This repository has been archived by the owner on May 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathinitializer_list
81 lines (69 loc) · 1.87 KB
/
initializer_list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// initializer_list standard header
#pragma once
#ifndef _INITIALIZER_LIST_
#define _INITIALIZER_LIST_
#ifndef RC_INVOKED
#include <cstddef>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,3)
#pragma push_macro("new")
#undef new
_STD_BEGIN
// TEMPLATE CLASS initializer_list
template<class _Elem>
class initializer_list
{ // list of pointers to elements
public:
typedef _Elem value_type;
typedef const _Elem& reference;
typedef const _Elem& const_reference;
typedef size_t size_type;
typedef const _Elem* iterator;
typedef const _Elem* const_iterator;
_CONST_FUN initializer_list() _NOEXCEPT
: _First(0), _Last(0)
{ // empty list
}
_CONST_FUN initializer_list(const _Elem *_First_arg,
const _Elem *_Last_arg) _NOEXCEPT
: _First(_First_arg), _Last(_Last_arg)
{ // construct with pointers
}
_CONST_FUN const _Elem *begin() const _NOEXCEPT
{ // get beginning of list
return (_First);
}
_CONST_FUN const _Elem *end() const _NOEXCEPT
{ // get end of list
return (_Last);
}
_CONST_FUN size_t size() const _NOEXCEPT
{ // get length of list
return ((size_t)(_Last - _First));
}
private:
const _Elem *_First;
const _Elem *_Last;
};
// TEMPLATE FUNCTION begin
template<class _Elem> inline
_CONST_FUN const _Elem *begin(initializer_list<_Elem> _Ilist) _NOEXCEPT
{ // get beginning of sequence
return (_Ilist.begin());
}
// TEMPLATE FUNCTION end
template<class _Elem> inline
_CONST_FUN const _Elem *end(initializer_list<_Elem> _Ilist) _NOEXCEPT
{ // get end of sequence
return (_Ilist.end());
}
_STD_END
#pragma pop_macro("new")
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _INITIALIZER_LIST_ */
/*
* Copyright (c) by P.J. Plauger. All rights reserved.
* Consult your license regarding permissions and restrictions.
V6.50:0009 */