mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-26 23:09:03 -04:00

This patch attempts to improve the QoI of std::tuples tuple_element and __make_tuple_types helpers. Previously they required O(N) instantiations, one for every element in the tuple The new implementations are O(1) after __tuple_indices<Id...> is created. llvm-svn: 274330
35 lines
953 B
C++
35 lines
953 B
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <tuple>
|
|
|
|
// template <class... Types> class tuple;
|
|
|
|
// template <size_t I, class... Types>
|
|
// class tuple_element<I, tuple<Types...> >
|
|
// {
|
|
// public:
|
|
// typedef Ti type;
|
|
// };
|
|
|
|
// UNSUPPORTED: c++98, c++03
|
|
|
|
#include <tuple>
|
|
#include <type_traits>
|
|
|
|
int main()
|
|
{
|
|
using T = std::tuple<int, long, void*>;
|
|
using E1 = typename std::tuple_element<1, T &>::type; // expected-error{{undefined template}}
|
|
using E2 = typename std::tuple_element<3, T>::type;
|
|
using E3 = typename std::tuple_element<4, T const>::type;
|
|
// expected-error@__tuple:* 2 {{static_assert failed}}
|
|
|
|
}
|