| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// UNSUPPORTED: c++03 |
| 10 |
|
| 11 |
// <valarray> |
| 12 |
|
| 13 |
// template<class T> class valarray; |
| 14 |
|
| 15 |
// valarray(initializer_list<value_type>); |
| 16 |
|
| 17 |
#include <valarray> |
| 18 |
#include <cassert> |
| 19 |
|
| 20 |
#include "test_macros.h" |
| 21 |
|
| 22 |
int main(int, char**) |
| 23 |
{ |
| 24 |
{ |
| 25 |
typedef int T; |
| 26 |
T a[] = {1, 2, 3, 4, 5}; |
| 27 |
const unsigned N = sizeof(a)/sizeof(a[0]); |
| 28 |
std::valarray<T> v = {1, 2, 3, 4, 5}; |
| 29 |
assert(v.size() == N); |
| 30 |
for (unsigned i = 0; i < N; ++i) |
| 31 |
assert(v[i] == a[i]); |
| 32 |
} |
| 33 |
{ |
| 34 |
typedef double T; |
| 35 |
T a[] = {1, 2, 3, 4, 5}; |
| 36 |
const unsigned N = sizeof(a)/sizeof(a[0]); |
| 37 |
std::valarray<T> v = {1, 2, 3, 4, 5}; |
| 38 |
assert(v.size() == N); |
| 39 |
for (unsigned i = 0; i < N; ++i) |
| 40 |
assert(v[i] == a[i]); |
| 41 |
} |
| 42 |
|
| 43 |
return 0; |
| 44 |
} |