68aa8078bdb6c5d3f6b1c5e6fb83b9c3d237510e
[oota-llvm.git] / include / Support / VectorExtras.h
1 //===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===//
2 //
3 // This file contains helper functions which are useful for working with the
4 // std::vector class.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef SUPPORT_VECTOREXTRAS_H
9 #define SUPPORT_VECTOREXTRAS_H
10
11 #include <cstdarg>
12
13 /// make_vector - Helper function which is useful for building temporary vectors
14 /// to pass into type construction of CallInst ctors.  This turns a null
15 /// terminated list of pointers (or other value types) into a real live vector.
16 ///
17 template<typename T>
18 inline std::vector<T> make_vector(T A, ...) {
19   va_list Args;
20   va_start(Args, A);
21   std::vector<T> Result;
22   Result.push_back(A);
23   while (T Val = va_arg(Args, T))
24     Result.push_back(Val);
25   va_end(Args);
26   return Result;
27 }
28
29 #endif