#include "llvm/ADT/SmallVector.h" #includeint main() { llvm::SmallVector vec = {1, 2, 3}; vec.push_back(4); std::cout << "Vector size: " << vec.size() << std::endl; std::cout << "Vector capacity: " << vec.capacity() << std::endl; std::cout << "Vector contents: "; for (int i : vec) { std::cout << i << " "; } std::cout << std::endl; vec.pop_back(); std::cout << "Vector contents after pop_back(): "; for (int i : vec) { std::cout << i << " "; } std::cout << std::endl; std::cout << "Vector end: " << *(vec.end() - 1) << std::endl; return 0; }
#include "llvm/ADT/SmallVector.h" #includeThis code creates a SmallVector with a maximum size of 3 and initializes it with the values 6, 2, and 8. It then sorts the vector using the `std::sort` algorithm and prints out the sorted contents and the value at the end of the vector. Package/Library: LLVM#include int main() { llvm::SmallVector vec = {6, 2, 8}; std::sort(vec.begin(), vec.end()); std::cout << "Sorted vector: "; for (int i : vec) { std::cout << i << " "; } std::cout << std::endl; std::cout << "Vector end: " << *(vec.end() - 1) << std::endl; return 0; }