default.pass.cpp revision 06086258d3d8c48a916ec51c33e1ad8f46821b81
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// dynarray.data
11
12// void fill(const T& v);
13// const T* data() const noexcept;
14
15
16#include <__config>
17
18#if _LIBCPP_STD_VER > 11
19
20#include <experimental/dynarray>
21#include <cassert>
22
23#include <algorithm>
24#include <complex>
25#include <string>
26
27using std::experimental::dynarray;
28
29template <class T>
30void test ( const T &val ) {
31    typedef dynarray<T> dynA;
32
33    dynA d1 ( 4 );
34    d1.fill ( val );
35    assert ( std::all_of ( d1.begin (), d1.end (),
36                    [&val]( const T &item ){ return item == val; } ));
37    }
38
39int main()
40{
41    test<int> ( 14 );
42    test<double> ( 14.0 );
43    test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
44    test<std::string> ( "fourteen" );
45}
46#else
47int main() {}
48#endif
49