LLVM API Documentation

VectorExtras.h

Go to the documentation of this file.
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 #include <vector>
00020 
00021 namespace llvm {
00022 
00023 /// make_vector - Helper function which is useful for building temporary vectors
00024 /// to pass into type construction of CallInst ctors.  This turns a null
00025 /// terminated list of pointers (or other value types) into a real live vector.
00026 ///
00027 template<typename T>
00028 inline std::vector<T> make_vector(T A, ...) {
00029   va_list Args;
00030   va_start(Args, A);
00031   std::vector<T> Result;
00032   Result.push_back(A);
00033   while (T Val = va_arg(Args, T))
00034     Result.push_back(Val);
00035   va_end(Args);
00036   return Result;
00037 }
00038 
00039 } // End llvm namespace
00040 
00041 #endif