#include#include int main() { llvm::SmallVector vec = {1, 2, 3}; vec.push_back(4); vec.push_back(5); vec.resize(10); std::cout << "The vector has " << vec.size() << " elements:"; for (auto el : vec) { std::cout << " " << el; } std::cout << std::endl; return 0; }
#includeIn this example, we create a function that takes a SmallVector as a constant reference parameter and prints out all its elements. We then create a SmallVector with 5 integers, fill it up, and pass it as an argument to our function. The SmallVector library is part of the LLVM (Low-Level Virtual Machine) project, which is a collection of modular and reusable compiler and toolchain components.#include void printVector(const llvm::SmallVector & vec) { std::cout << "The vector has " << vec.size() << " elements:"; for (auto el : vec) { std::cout << " " << el; } std::cout << std::endl; } int main() { llvm::SmallVector vec = {1, 2, 3}; vec.push_back(4); vec.push_back(5); printVector(vec); return 0; }