#include "llvm/ADT/SmallVector.h" int main() { llvm::SmallVectorvec; vec.push_back(1); vec.push_back(2); vec.push_back(3); return 0; }
#includeIn this example, we create a SmallVector of integers named vec1 with an initial capacity of 3 and add 3 elements to it. We then create another SmallVector named vec2 and assign vec1 to it. Finally, we print both vectors to the console to ensure that vec2 is a copy of vec1. This code uses the SmallVector library provided by the LLVM project.#include #include "llvm/ADT/SmallVector.h" int main() { llvm::SmallVector vec1 = { 1, 2, 3 }; llvm::SmallVector vec2; vec2 = vec1; std::cout << "vec1: "; for (const auto& elem : vec1) { std::cout << elem << " "; } std::cout << "\nvec2: "; for (const auto& elem : vec2) { std::cout << elem << " "; } return 0; }