Added LLVM notice.
[oota-llvm.git] / include / llvm / ADT / 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 /// make_vector - Helper function which is useful for building temporary vectors
21 /// to pass into type construction of CallInst ctors.  This turns a null
22 /// terminated list of pointers (or other value types) into a real live vector.
23 ///
24 template<typename T>
25 inline std::vector<T> make_vector(T A, ...) {
26   va_list Args;
27   va_start(Args, A);
28   std::vector<T> Result;
29   Result.push_back(A);
30   while (T Val = va_arg(Args, T))
31     Result.push_back(Val);
32   va_end(Args);
33   return Result;
34 }
35
36 #endif