728x90
반응형
- begin(), end() 함수 사용
#include <iostream>
#include <vector>
#include <list>
#include <iterator>
using namespace std;
template<typename T> void show (T& c)
{
auto p1 = begin(c);
auto p2 = end(c);
while (p1 != p2)
{
cout << *p1 << endl;
++p1;
}
}
int main()
{
list<int> a = {1, 2, 3};
vector<int> b = {1, 2, 3};
int c[3] = {1, 2, 3};
show(a);
show(b);
show(c);
}
728x90
반응형
'개발' 카테고리의 다른 글
QT, QML Reference (0) | 2020.03.26 |
---|---|
modern C++ 스마트포인터 unique_ptr (1) | 2019.12.26 |
modern C++ noexcept (0) | 2019.12.15 |
modern C++ using 사용법 (0) | 2019.12.15 |
modern C++ static_assert (0) | 2019.12.15 |