Member Functions of std::initializer_list
The following are some of the commonly used member functions of the std::initialzer_list class:
S. No. |
Function Name |
Description |
---|---|---|
1 |
begin() |
Returns a pointer to the first element of the initializer list. |
2 |
end() |
Returns a pointer to the last element of the initializer list. |
3 |
size() |
The size() function returns the number of elements present in the initializer list. |
4 |
empty() |
This function returns true if the initializer list is empty. False otherwise. |
5 |
data() |
Returns a pointer to the underlying array container. |
std::initializer_list in C++ 11
The std::initializer_list class template was added in C++ 11 and contains many built-in functions to perform various operations with the initializer list. It provides member functions like a size(), begin(), end(), and constructor to construct, iterate, and access elements of the initializer list.
To use initializer_list, you need to include the <initializer_list> header in your C++ program.
Contact Us