int arr[] = {1, 2, 3}; auto it = std::begin(arr); for(; it != std::end(arr); ++it){ std::cout << *it << "\n"; // output: 1 2 3 }
std::vectorThis example shows the usage of `std::begin` to get an iterator to the beginning of a vector. Package/library: Standard Library (included in C++)vec = {4, 5, 6}; auto it = std::begin(vec); for(; it != std::end(vec); ++it){ std::cout << *it << "\n"; // output: 4 5 6 }