We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8f0c3b commit a670f4fCopy full SHA for a670f4f
cpp_17/009_initializer_list_empty.cpp
@@ -1 +1,32 @@
1
-1
+#include <iostream>
2
+#include <vector>
3
+
4
+template <class T>
5
+void print(const T& container)
6
+{
7
+ if ( std::empty(container) )
8
+ {
9
+ std::cout << "Empty\n";
10
+ }
11
+ else
12
13
+ std::cout << "Elements:";
14
+ for ( const auto& element : container )
15
+ std::cout << ' ' << element;
16
+ std::cout << '\n';
17
18
+}
19
20
+int main()
21
22
+ std::vector<int> c = { 1, 2, 3 };
23
+ print(c);
24
+ c.clear();
25
26
27
+ int array[] = { 4, 5, 6 };
28
+ print(array);
29
30
+ auto il = { 7, 8, 9 };
31
+ print(il);
32
0 commit comments