VLCB
Toggle main menu visibility
Loading...
Searching...
No Matches
initializer_list.h
Go to the documentation of this file.
1
// Copyright (C) Sven Rosvall (sven@rosvall.ie)
2
// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3
// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4
// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0/
5
6
// Use the same include guard as GNU C++ and Clang uses so that this doesn't clash for running the test suite.
7
// Note the double include guard macros as GNU C++ and Clang use different include guard macros.
8
#if !defined(_INITIALIZER_LIST) && !defined(_LIBCPP_INITIALIZER_LIST)
9
#define _INITIALIZER_LIST
// GNU C++
10
#define _LIBCPP_INITIALIZER_LIST
// Clang
11
12
#include <stddef.h>
13
14
namespace
std
15
{
17
template
<
class
E>
18
class
initializer_list
19
{
20
public
:
21
22
constexpr
initializer_list
() noexcept : array(0), len(0) { }
23
24
// Number of elements.
25
constexpr
size_t
26
size
() const noexcept {
return
len; }
27
28
// First element.
29
constexpr
const
E*
30
begin
() const noexcept {
return
array; }
31
32
// One past the last element.
33
constexpr
const
E*
34
end
() const noexcept {
return
begin
() +
size
(); }
35
36
// private:
37
// The compiler uses this
38
constexpr
initializer_list
(
const
E* a,
size_t
l)
39
: array(a), len(l) { }
40
41
private
:
42
const
E* array;
43
size_t
len;
44
};
45
46
template
<
class
T>
47
constexpr
const
T*
48
begin
(
initializer_list<T>
ils)
noexcept
49
{
return
ils.begin(); }
50
51
template
<
class
T>
52
constexpr
const
T*
53
end
(
initializer_list<T>
ils)
noexcept
54
{
return
ils.end(); }
55
}
56
57
#endif
std::initializer_list
Convenience class for use with initializer lists, i.e. bracketed list of items: { a,...
Definition
initializer_list.h:19
std::initializer_list::begin
constexpr const E * begin() const noexcept
Definition
initializer_list.h:30
std::initializer_list::end
constexpr const E * end() const noexcept
Definition
initializer_list.h:34
std::initializer_list::initializer_list
constexpr initializer_list(const E *a, size_t l)
Definition
initializer_list.h:38
std::initializer_list::initializer_list
constexpr initializer_list() noexcept
Definition
initializer_list.h:22
std::initializer_list::size
constexpr size_t size() const noexcept
Definition
initializer_list.h:26
std
Definition
initializer_list.h:15
std::begin
constexpr const T * begin(initializer_list< T > ils) noexcept
Definition
initializer_list.h:48
std::end
constexpr const T * end(initializer_list< T > ils) noexcept
Definition
initializer_list.h:53
src
initializer_list.h
Generated by
1.18.0