]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/26_numerics/reduce/2.cc
1 // { dg-options "-std=gnu++17" }
2 // { dg-do compile { target c++17 } }
4 // Copyright (C) 2019-2020 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // C++17 29.8.3 [reduce]
25 #include <testsuite_hooks.h>
26 #include <testsuite_iterators.h>
31 T(T
&&); // MoveConstructible
32 T
& operator=(T
&&); // not required by the standard, but it needs to be
33 T
operator+(const T
&) const;
40 std::reduce(t
, t
+1, T(0));
42 using __gnu_test::test_container
;
43 using __gnu_test::input_iterator_wrapper
;
44 test_container
<T
, input_iterator_wrapper
> con(t
);
45 std::reduce(con
.begin(), con
.end(), T(0));
50 T
operator()(T
&, T
&) const&;
52 // The standard does *not* require invoking as an rvalue to be supported.
53 T
operator()(T
&, T
&) && = delete;
55 // The standard does *not* require rvalue arguments to be supported
56 // (this is almost certainly a defect and should be allowed).
57 T
operator()(T
&&, T
&&) const = delete;
64 std::reduce(t
, t
+1, T(0), Op());
66 using __gnu_test::test_container
;
67 using __gnu_test::input_iterator_wrapper
;
68 test_container
<T
, input_iterator_wrapper
> con(t
);
69 std::reduce(con
.begin(), con
.end(), T(0), Op());