labs-edaf30/lab1/buggy_programs/ub.cc
Sven Gestegard Robertz e4df45f4a9 imported lab skeletons
2021-10-27 15:39:22 +02:00

31 lines
456 B
C++

#include <iostream>
#include <vector>
#include <cassert>
#include <numeric>
using std::cout;
using std::endl;
std::vector<int> create_vector(int s)
{
assert(s >= 0);
std::vector<int> res(s);
}
template <typename C>
void print_seq(const C& c)
{
for(const auto& x : c) cout << x << " ";
cout << "\n";
}
void example()
{
auto v = create_vector(10);
std::iota(begin(v), end(v), 0);
print_seq(v);
}
int main()
{
example();
}