LLVM API Documentation
00001 //===-- llvm/ADT/VectorExtras.h - Helpers for std::vector -------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains helper functions which are useful for working with the 00011 // std::vector class. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_ADT_VECTOREXTRAS_H 00016 #define LLVM_ADT_VECTOREXTRAS_H 00017 00018 #include <cstdarg> 00019 00020 namespace llvm { 00021 00022 /// make_vector - Helper function which is useful for building temporary vectors 00023 /// to pass into type construction of CallInst ctors. This turns a null 00024 /// terminated list of pointers (or other value types) into a real live vector. 00025 /// 00026 template<typename T> 00027 inline std::vector<T> make_vector(T A, ...) { 00028 va_list Args; 00029 va_start(Args, A); 00030 std::vector<T> Result; 00031 Result.push_back(A); 00032 while (T Val = va_arg(Args, T)) 00033 Result.push_back(Val); 00034 va_end(Args); 00035 return Result; 00036 } 00037 00038 } // End llvm namespace 00039 00040 #endif