libcxx initial import
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
28
test/containers/sequences/array/array.tuple/get.pass.cpp
Normal file
28
test/containers/sequences/array/array.tuple/get.pass.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <array>
|
||||
|
||||
// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
C c = {1, 2, 3.5};
|
||||
std::get<1>(c) = 5.5;
|
||||
assert(c[0] == 1);
|
||||
assert(c[1] == 5.5);
|
||||
assert(c[2] == 3.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <array>
|
||||
|
||||
// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
const C c = {1, 2, 3.5};
|
||||
assert(std::get<0>(c) == 1);
|
||||
assert(std::get<1>(c) == 2);
|
||||
assert(std::get<2>(c) == 3.5);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <array>
|
||||
|
||||
// tuple_element<I, array<T, N> >::type
|
||||
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
|
||||
}
|
||||
{
|
||||
typedef int T;
|
||||
typedef std::array<T, 3> C;
|
||||
static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
|
||||
static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <array>
|
||||
|
||||
// tuple_size<array<T, N> >::value
|
||||
|
||||
#include <array>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
static_assert((std::tuple_size<C>::value == 3), "");
|
||||
}
|
||||
{
|
||||
typedef double T;
|
||||
typedef std::array<T, 0> C;
|
||||
static_assert((std::tuple_size<C>::value == 0), "");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user