summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-07-01 01:24:09 +0000
committerEric Fiselier <eric@efcs.ca>2016-07-01 01:24:09 +0000
commitfe36cf9482c47d38d36d71965469f21813c22277 (patch)
tree57a6fb3fa7328b9dad05d3207748e3d64788e1fe /test/PCH
parente1f24a2b85f06fedcacf7ee6ac31a25a25f697ce (diff)
[Feature] Add a builtin for indexing into parameter packs. Patch by Louis Dionne.
This patch adds a __nth_element builtin that allows fetching the n-th type of a parameter pack with very little compile-time overhead. The patch was inspired by r252036 and r252115 by David Majnemer, which add a similar __make_integer_seq builtin for efficiently creating a std::integer_sequence. Reviewed as D15421. http://reviews.llvm.org/D15421 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/type_pack_element.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/PCH/type_pack_element.cpp b/test/PCH/type_pack_element.cpp
new file mode 100644
index 0000000000..c4ed6c81e2
--- /dev/null
+++ b/test/PCH/type_pack_element.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
+template <int i>
+struct X { };
+
+using SizeT = decltype(sizeof(int));
+
+template <SizeT i, typename ...T>
+using TypePackElement = __type_pack_element<i, T...>;
+
+void fn1() {
+ X<0> x0 = TypePackElement<0, X<0>, X<1>, X<2>>{};
+ X<1> x1 = TypePackElement<1, X<0>, X<1>, X<2>>{};
+ X<2> x2 = TypePackElement<2, X<0>, X<1>, X<2>>{};
+}