cf7cf5d2ebb7ff410fd55f27a689934c41a19bda
[oota-llvm.git] / include / Support / VectorExtras.h
1 //===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains helper functions which are useful for working with the
11 // std::vector class.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef SUPPORT_VECTOREXTRAS_H
16 #define SUPPORT_VECTOREXTRAS_H
17
18 #include <cstdarg>
19
20 namespace llvm {
21
22 /// make_vector - Helper function which is useful for building temporary vectors
23 /// to pass into type construction of CallInst ctors.  This turns a null
24 /// terminated list of pointers (or other value types) into a real live vector.
25 ///
26 template<typename T>
27 inline std::vector<T> make_vector(T A, ...) {
28   va_list Args;
29   va_start(Args, A);
30   std::vector<T> Result;
31   Result.push_back(A);
32   while (T Val = va_arg(Args, T))
33     Result.push_back(Val);
34   va_end(Args);
35   return Result;
36 }
37
38 } // End llvm namespace
39
40 #endif