]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/dr1339.cc
1 // Copyright (C) 2014-2020 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
19 #include <testsuite_hooks.h>
21 // test specialization for trivial types
28 const int over9000
= 9001;
29 int* end
= std::uninitialized_fill_n(arr
, n
, over9000
);
30 VERIFY( end
= arr
+ n
);
31 for (int i
= 0; i
< n
; ++i
)
32 VERIFY( arr
[i
] == over9000
);
33 for (int i
= n
; i
< N
; ++i
)
34 VERIFY( arr
[i
] == 0 );
40 T(const T
&) { ++counter
; }
51 char* mem
= new char[sizeof(T
)*n
];
52 T
* p
= reinterpret_cast<T
*>(mem
);
53 T
* end
= std::uninitialized_fill_n(p
, n
, T());
54 VERIFY( end
= p
+ n
);
55 VERIFY( T::counter
== n
);