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 // <forward_list> 10 11 // void reverse(); 12 13 #include <forward_list> 14 #include <iterator> 15 #include <algorithm> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "min_allocator.h" 20 21 template <class C> test(int N)22void test(int N) 23 { 24 C c; 25 for (int i = 0; i < N; ++i) 26 c.push_front(i); 27 c.reverse(); 28 assert(std::distance(c.begin(), c.end()) == N); 29 typename C::const_iterator j = c.begin(); 30 for (int i = 0; i < N; ++i, ++j) 31 assert(*j == i); 32 } 33 main(int,char **)34int main(int, char**) 35 { 36 for (int i = 0; i < 10; ++i) 37 test<std::forward_list<int> >(i); 38 #if TEST_STD_VER >= 11 39 for (int i = 0; i < 10; ++i) 40 test<std::forward_list<int, min_allocator<int>> >(i); 41 #endif 42 43 return 0; 44 } 45