llvm.org GIT mirror llvm / fd373cb
Initial checking: defult the make_vector function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5424 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
2 changed file(s) with 58 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===//
1 //
2 // This file contains helper functions which are useful for working with the
3 // std::vector class.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef SUPPORT_VECTOREXTRAS_H
8 #define SUPPORT_VECTOREXTRAS_H
9
10 #include
11
12 /// make_vector - Helper function which is useful for building temporary vectors
13 /// to pass into type construction of CallInst ctors. This turns a null
14 /// terminated list of pointers (or other value types) into a real live vector.
15 ///
16 template
17 inline std::vector make_vector(T A, ...) {
18 va_list Args;
19 va_start(Args, A);
20 std::vector Result;
21 Result.push_back(A);
22 while (T Val = va_arg(Args, T))
23 Result.push_back(Val);
24 va_end(Args);
25 return Result;
26 }
27
28 #endif
0 //===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===//
1 //
2 // This file contains helper functions which are useful for working with the
3 // std::vector class.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef SUPPORT_VECTOREXTRAS_H
8 #define SUPPORT_VECTOREXTRAS_H
9
10 #include
11
12 /// make_vector - Helper function which is useful for building temporary vectors
13 /// to pass into type construction of CallInst ctors. This turns a null
14 /// terminated list of pointers (or other value types) into a real live vector.
15 ///
16 template
17 inline std::vector make_vector(T A, ...) {
18 va_list Args;
19 va_start(Args, A);
20 std::vector Result;
21 Result.push_back(A);
22 while (T Val = va_arg(Args, T))
23 Result.push_back(Val);
24 va_end(Args);
25 return Result;
26 }
27
28 #endif