xref: /llvm-project/libcxx/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 // <valarray>
10 
11 // template<class T> class valarray;
12 
13 // valarray();
14 
15 #include <valarray>
16 #include <cassert>
17 
18 struct S {
19     S() { ctor_called = true; }
20     static bool ctor_called;
21 };
22 
23 bool S::ctor_called = false;
24 
25 int main()
26 {
27     {
28         std::valarray<int> v;
29         assert(v.size() == 0);
30     }
31     {
32         std::valarray<float> v;
33         assert(v.size() == 0);
34     }
35     {
36         std::valarray<double> v;
37         assert(v.size() == 0);
38     }
39     {
40         std::valarray<std::valarray<double> > v;
41         assert(v.size() == 0);
42     }
43     {
44         std::valarray<S> v;
45         assert(v.size() == 0);
46         assert(!S::ctor_called);
47     }
48 }
49