get_const.pass.cpp revision 8fc4f5a2510e709331c6fcc3ba401a36f98128fc
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <utility>
11
12// template <class T1, class T2> struct pair
13
14// template<size_t I, class T1, class T2>
15//     const typename tuple_element<I, std::pair<T1, T2> >::type&
16//     get(const pair<T1, T2>&);
17
18#include <utility>
19#include <cassert>
20
21int main()
22{
23    {
24        typedef std::pair<int, short> P;
25        const P p(3, 4);
26        assert(std::get<0>(p) == 3);
27        assert(std::get<1>(p) == 4);
28    }
29
30#if __cplusplus > 201103L
31    {
32        typedef std::pair<int, short> P;
33        constexpr P p1(3, 4);
34        static_assert(std::get<0>(p1) == 3, "");
35        static_assert(std::get<1>(p1) == 4, "");
36    }
37#endif
38}
39