2007-03-04 23:59:49 +01:00
|
|
|
// <array> -*- C++ -*-
|
|
|
|
|
2020-01-01 12:51:42 +01:00
|
|
|
// Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
2007-03-04 23:59:49 +01:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2007-03-04 23:59:49 +01:00
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
2007-03-04 23:59:49 +01:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2007-03-04 23:59:49 +01:00
|
|
|
|
|
|
|
/** @file include/array
|
|
|
|
* This is a Standard C++ Library header.
|
|
|
|
*/
|
|
|
|
|
2008-04-10 21:02:57 +02:00
|
|
|
#ifndef _GLIBCXX_ARRAY
|
|
|
|
#define _GLIBCXX_ARRAY 1
|
2007-03-04 23:59:49 +01:00
|
|
|
|
|
|
|
#pragma GCC system_header
|
|
|
|
|
2012-11-10 18:27:22 +01:00
|
|
|
#if __cplusplus < 201103L
|
2010-02-10 20:14:33 +01:00
|
|
|
# include <bits/c++0x_warning.h>
|
2008-05-26 04:19:57 +02:00
|
|
|
#else
|
2007-03-04 23:59:49 +01:00
|
|
|
|
2015-06-23 21:51:02 +02:00
|
|
|
#include <utility>
|
2019-06-06 17:34:56 +02:00
|
|
|
#include <bits/functexcept.h>
|
2007-06-01 01:37:56 +02:00
|
|
|
#include <bits/stl_algobase.h>
|
2010-07-27 19:27:06 +02:00
|
|
|
#include <bits/range_access.h>
|
2007-06-01 01:37:56 +02:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
2012-11-07 01:42:19 +01:00
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2012-10-04 02:02:29 +02:00
|
|
|
template<typename _Tp, std::size_t _Nm>
|
|
|
|
struct __array_traits
|
|
|
|
{
|
|
|
|
typedef _Tp _Type[_Nm];
|
2016-06-16 17:07:19 +02:00
|
|
|
typedef __is_swappable<_Tp> _Is_swappable;
|
|
|
|
typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable;
|
2012-10-04 02:02:29 +02:00
|
|
|
|
|
|
|
static constexpr _Tp&
|
|
|
|
_S_ref(const _Type& __t, std::size_t __n) noexcept
|
|
|
|
{ return const_cast<_Tp&>(__t[__n]); }
|
2015-05-28 13:53:35 +02:00
|
|
|
|
|
|
|
static constexpr _Tp*
|
|
|
|
_S_ptr(const _Type& __t) noexcept
|
|
|
|
{ return const_cast<_Tp*>(__t); }
|
2012-10-04 02:02:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
struct __array_traits<_Tp, 0>
|
|
|
|
{
|
|
|
|
struct _Type { };
|
2016-06-16 17:07:19 +02:00
|
|
|
typedef true_type _Is_swappable;
|
|
|
|
typedef true_type _Is_nothrow_swappable;
|
2012-10-04 02:02:29 +02:00
|
|
|
|
|
|
|
static constexpr _Tp&
|
|
|
|
_S_ref(const _Type&, std::size_t) noexcept
|
|
|
|
{ return *static_cast<_Tp*>(nullptr); }
|
2015-05-28 13:53:35 +02:00
|
|
|
|
|
|
|
static constexpr _Tp*
|
|
|
|
_S_ptr(const _Type&) noexcept
|
|
|
|
{ return nullptr; }
|
2012-10-04 02:02:29 +02:00
|
|
|
};
|
|
|
|
|
2010-11-02 19:51:23 +01:00
|
|
|
/**
|
|
|
|
* @brief A standard container for storing a fixed size sequence of elements.
|
|
|
|
*
|
|
|
|
* @ingroup sequences
|
|
|
|
*
|
|
|
|
* Meets the requirements of a <a href="tables.html#65">container</a>, a
|
|
|
|
* <a href="tables.html#66">reversible container</a>, and a
|
|
|
|
* <a href="tables.html#67">sequence</a>.
|
|
|
|
*
|
|
|
|
* Sets support random access iterators.
|
|
|
|
*
|
2012-05-03 00:25:28 +02:00
|
|
|
* @tparam Tp Type of element. Required to be a complete type.
|
2019-08-08 12:18:53 +02:00
|
|
|
* @tparam Nm Number of elements.
|
2010-11-02 19:51:23 +01:00
|
|
|
*/
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
|
|
|
struct array
|
|
|
|
{
|
|
|
|
typedef _Tp value_type;
|
2011-09-07 02:17:09 +02:00
|
|
|
typedef value_type* pointer;
|
|
|
|
typedef const value_type* const_pointer;
|
2010-11-02 19:51:23 +01:00
|
|
|
typedef value_type& reference;
|
|
|
|
typedef const value_type& const_reference;
|
|
|
|
typedef value_type* iterator;
|
|
|
|
typedef const value_type* const_iterator;
|
|
|
|
typedef std::size_t size_type;
|
|
|
|
typedef std::ptrdiff_t difference_type;
|
|
|
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
|
|
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
|
|
|
|
|
|
// Support for zero-sized arrays mandatory.
|
2012-11-07 01:42:19 +01:00
|
|
|
typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
|
|
|
|
typename _AT_Type::_Type _M_elems;
|
2010-11-02 19:51:23 +01:00
|
|
|
|
|
|
|
// No explicit construct/copy/destroy for aggregate type.
|
|
|
|
|
|
|
|
// DR 776.
|
2019-11-15 01:09:49 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR void
|
2010-11-02 19:51:23 +01:00
|
|
|
fill(const value_type& __u)
|
|
|
|
{ std::fill_n(begin(), size(), __u); }
|
|
|
|
|
2019-11-15 01:09:49 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR void
|
2010-11-02 19:51:23 +01:00
|
|
|
swap(array& __other)
|
2016-06-16 17:07:19 +02:00
|
|
|
noexcept(_AT_Type::_Is_nothrow_swappable::value)
|
2010-11-02 19:51:23 +01:00
|
|
|
{ std::swap_ranges(begin(), end(), __other.begin()); }
|
|
|
|
|
|
|
|
// Iterators.
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
begin() noexcept
|
2011-09-07 02:17:09 +02:00
|
|
|
{ return iterator(data()); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
begin() const noexcept
|
2011-09-07 02:17:09 +02:00
|
|
|
{ return const_iterator(data()); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
end() noexcept
|
2011-09-07 02:17:09 +02:00
|
|
|
{ return iterator(data() + _Nm); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
end() const noexcept
|
2011-09-07 02:17:09 +02:00
|
|
|
{ return const_iterator(data() + _Nm); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR reverse_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
rbegin() noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return reverse_iterator(end()); }
|
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
rbegin() const noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return const_reverse_iterator(end()); }
|
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR reverse_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
rend() noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return reverse_iterator(begin()); }
|
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
rend() const noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return const_reverse_iterator(begin()); }
|
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
cbegin() const noexcept
|
2012-10-04 02:02:29 +02:00
|
|
|
{ return const_iterator(data()); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
cend() const noexcept
|
2012-10-04 02:02:29 +02:00
|
|
|
{ return const_iterator(data() + _Nm); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
crbegin() const noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return const_reverse_iterator(end()); }
|
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_reverse_iterator
|
2011-05-16 20:09:17 +02:00
|
|
|
crend() const noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return const_reverse_iterator(begin()); }
|
|
|
|
|
|
|
|
// Capacity.
|
2016-06-16 15:47:35 +02:00
|
|
|
constexpr size_type
|
2011-05-16 20:09:17 +02:00
|
|
|
size() const noexcept { return _Nm; }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2016-06-16 15:47:35 +02:00
|
|
|
constexpr size_type
|
2011-05-16 20:09:17 +02:00
|
|
|
max_size() const noexcept { return _Nm; }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2019-01-21 12:47:30 +01:00
|
|
|
_GLIBCXX_NODISCARD constexpr bool
|
2011-05-16 20:09:17 +02:00
|
|
|
empty() const noexcept { return size() == 0; }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
|
|
|
// Element access.
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR reference
|
re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
_M_const_cast, operator*, operator->, operator++, operator--,
operator[], operator+=, operator+, operator-=, operator-, base]:
Mark as noexcept.
(operator==(const __normal_iterator&, const __normal_iterator&),
operator!=(const __normal_iterator&, const __normal_iterator&),
operator<(const __normal_iterator&, const __normal_iterator&),
operator>(const __normal_iterator&, const __normal_iterator&),
operator<=(const __normal_iterator&, const __normal_iterator&),
operator>=(const __normal_iterator&, const __normal_iterator&),
operator-(const __normal_iterator&, const __normal_iterator&),
operator+(difference_type, const __normal_iterator&)): Likewise.
* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
Likewise.
(list::_M_check_equal_allocators): Abort instead of throwing.
* include/debug/array (array) [operator[], front, back]: Mark as
noexcept.
* include/profile/array (array) [operator[], front, back]: Likewise.
* include/std/array (array) [operator[], front, back]: Likewise.
* include/debug/list (list::splice): Likewise.
* include/profile/list (list::splice): Likewise.
* testsuite/23_containers/list/operations/5.cc: Remove file.
* testsuite/23_containers/list/operations/5.h: Likewise.
From-SVN: r202716
2013-09-18 20:31:01 +02:00
|
|
|
operator[](size_type __n) noexcept
|
2012-10-04 02:02:29 +02:00
|
|
|
{ return _AT_Type::_S_ref(_M_elems, __n); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2011-07-21 07:48:03 +02:00
|
|
|
constexpr const_reference
|
|
|
|
operator[](size_type __n) const noexcept
|
2012-10-04 02:02:29 +02:00
|
|
|
{ return _AT_Type::_S_ref(_M_elems, __n); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR reference
|
2010-11-02 19:51:23 +01:00
|
|
|
at(size_type __n)
|
|
|
|
{
|
|
|
|
if (__n >= _Nm)
|
2013-09-22 04:04:13 +02:00
|
|
|
std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
|
|
|
|
">= _Nm (which is %zu)"),
|
|
|
|
__n, _Nm);
|
2012-10-04 02:02:29 +02:00
|
|
|
return _AT_Type::_S_ref(_M_elems, __n);
|
2010-11-02 19:51:23 +01:00
|
|
|
}
|
|
|
|
|
2011-07-21 07:48:03 +02:00
|
|
|
constexpr const_reference
|
2010-11-02 19:51:23 +01:00
|
|
|
at(size_type __n) const
|
|
|
|
{
|
2012-09-09 19:56:51 +02:00
|
|
|
// Result of conditional expression must be an lvalue so use
|
|
|
|
// boolean ? lvalue : (throw-expr, lvalue)
|
2012-10-04 02:02:29 +02:00
|
|
|
return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
|
2013-09-22 04:04:13 +02:00
|
|
|
: (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
|
|
|
|
">= _Nm (which is %zu)"),
|
|
|
|
__n, _Nm),
|
2012-10-04 02:02:29 +02:00
|
|
|
_AT_Type::_S_ref(_M_elems, 0));
|
2011-07-26 06:21:57 +02:00
|
|
|
}
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR reference
|
re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
_M_const_cast, operator*, operator->, operator++, operator--,
operator[], operator+=, operator+, operator-=, operator-, base]:
Mark as noexcept.
(operator==(const __normal_iterator&, const __normal_iterator&),
operator!=(const __normal_iterator&, const __normal_iterator&),
operator<(const __normal_iterator&, const __normal_iterator&),
operator>(const __normal_iterator&, const __normal_iterator&),
operator<=(const __normal_iterator&, const __normal_iterator&),
operator>=(const __normal_iterator&, const __normal_iterator&),
operator-(const __normal_iterator&, const __normal_iterator&),
operator+(difference_type, const __normal_iterator&)): Likewise.
* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
Likewise.
(list::_M_check_equal_allocators): Abort instead of throwing.
* include/debug/array (array) [operator[], front, back]: Mark as
noexcept.
* include/profile/array (array) [operator[], front, back]: Likewise.
* include/std/array (array) [operator[], front, back]: Likewise.
* include/debug/list (list::splice): Likewise.
* include/profile/list (list::splice): Likewise.
* testsuite/23_containers/list/operations/5.cc: Remove file.
* testsuite/23_containers/list/operations/5.h: Likewise.
From-SVN: r202716
2013-09-18 20:31:01 +02:00
|
|
|
front() noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return *begin(); }
|
|
|
|
|
2016-06-16 15:47:35 +02:00
|
|
|
constexpr const_reference
|
re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
_M_const_cast, operator*, operator->, operator++, operator--,
operator[], operator+=, operator+, operator-=, operator-, base]:
Mark as noexcept.
(operator==(const __normal_iterator&, const __normal_iterator&),
operator!=(const __normal_iterator&, const __normal_iterator&),
operator<(const __normal_iterator&, const __normal_iterator&),
operator>(const __normal_iterator&, const __normal_iterator&),
operator<=(const __normal_iterator&, const __normal_iterator&),
operator>=(const __normal_iterator&, const __normal_iterator&),
operator-(const __normal_iterator&, const __normal_iterator&),
operator+(difference_type, const __normal_iterator&)): Likewise.
* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
Likewise.
(list::_M_check_equal_allocators): Abort instead of throwing.
* include/debug/array (array) [operator[], front, back]: Mark as
noexcept.
* include/profile/array (array) [operator[], front, back]: Likewise.
* include/std/array (array) [operator[], front, back]: Likewise.
* include/debug/list (list::splice): Likewise.
* include/profile/list (list::splice): Likewise.
* testsuite/23_containers/list/operations/5.cc: Remove file.
* testsuite/23_containers/list/operations/5.h: Likewise.
From-SVN: r202716
2013-09-18 20:31:01 +02:00
|
|
|
front() const noexcept
|
2012-10-18 10:36:06 +02:00
|
|
|
{ return _AT_Type::_S_ref(_M_elems, 0); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR reference
|
re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
_M_const_cast, operator*, operator->, operator++, operator--,
operator[], operator+=, operator+, operator-=, operator-, base]:
Mark as noexcept.
(operator==(const __normal_iterator&, const __normal_iterator&),
operator!=(const __normal_iterator&, const __normal_iterator&),
operator<(const __normal_iterator&, const __normal_iterator&),
operator>(const __normal_iterator&, const __normal_iterator&),
operator<=(const __normal_iterator&, const __normal_iterator&),
operator>=(const __normal_iterator&, const __normal_iterator&),
operator-(const __normal_iterator&, const __normal_iterator&),
operator+(difference_type, const __normal_iterator&)): Likewise.
* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
Likewise.
(list::_M_check_equal_allocators): Abort instead of throwing.
* include/debug/array (array) [operator[], front, back]: Mark as
noexcept.
* include/profile/array (array) [operator[], front, back]: Likewise.
* include/std/array (array) [operator[], front, back]: Likewise.
* include/debug/list (list::splice): Likewise.
* include/profile/list (list::splice): Likewise.
* testsuite/23_containers/list/operations/5.cc: Remove file.
* testsuite/23_containers/list/operations/5.h: Likewise.
From-SVN: r202716
2013-09-18 20:31:01 +02:00
|
|
|
back() noexcept
|
2010-11-02 19:51:23 +01:00
|
|
|
{ return _Nm ? *(end() - 1) : *end(); }
|
|
|
|
|
2016-06-16 15:47:35 +02:00
|
|
|
constexpr const_reference
|
re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
2013-09-18 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/58338
* include/bits/stl_iterator.h (__normal_iterator) [__normal_iterator,
_M_const_cast, operator*, operator->, operator++, operator--,
operator[], operator+=, operator+, operator-=, operator-, base]:
Mark as noexcept.
(operator==(const __normal_iterator&, const __normal_iterator&),
operator!=(const __normal_iterator&, const __normal_iterator&),
operator<(const __normal_iterator&, const __normal_iterator&),
operator>(const __normal_iterator&, const __normal_iterator&),
operator<=(const __normal_iterator&, const __normal_iterator&),
operator>=(const __normal_iterator&, const __normal_iterator&),
operator-(const __normal_iterator&, const __normal_iterator&),
operator+(difference_type, const __normal_iterator&)): Likewise.
* include/bits/stl_list.h (list) [splice, _M_check_equal_allocators]:
Likewise.
(list::_M_check_equal_allocators): Abort instead of throwing.
* include/debug/array (array) [operator[], front, back]: Mark as
noexcept.
* include/profile/array (array) [operator[], front, back]: Likewise.
* include/std/array (array) [operator[], front, back]: Likewise.
* include/debug/list (list::splice): Likewise.
* include/profile/list (list::splice): Likewise.
* testsuite/23_containers/list/operations/5.cc: Remove file.
* testsuite/23_containers/list/operations/5.h: Likewise.
From-SVN: r202716
2013-09-18 20:31:01 +02:00
|
|
|
back() const noexcept
|
2016-06-16 15:47:35 +02:00
|
|
|
{
|
|
|
|
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
|
2012-11-07 01:42:19 +01:00
|
|
|
: _AT_Type::_S_ref(_M_elems, 0);
|
2012-10-18 10:36:06 +02:00
|
|
|
}
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR pointer
|
2011-05-16 20:09:17 +02:00
|
|
|
data() noexcept
|
2015-05-28 13:53:35 +02:00
|
|
|
{ return _AT_Type::_S_ptr(_M_elems); }
|
2010-11-02 19:51:23 +01:00
|
|
|
|
Add constexpr to <iterator> and <array> for C++17
* include/bits/c++config (_GLIBCXX17_CONSTEXPR): Define.
* include/bits/range_access.h (begin, end, rbegin, rend, crbegin)
(crend): Add _GLIBCXX17_CONSTEXPR as per P0031R0.
* include/bits/stl_iterator.h (reverse_iterator, move_iterator)
(__make_reverse_iterator, make_reverse_iterator, make_move_iterator):
Likewise.
* include/bits/stl_iterator_base_funcs.h (__distance, __advance): Add
_GLIBCXX14_CONSTEXPR.
(distance, advance, next, prev): Add _GLIBCXX17_CONSTEXPR.
* include/std/array (array::begin, array::end, array::rbegin)
(array::rend, array::cbegin, array:cend, array::crbegin)
(array::crend, array::operator[], array::at, array::front)
(array::back, array::data): Likewise.
* testsuite/24_iterators/headers/iterator/range_access.cc: Replace
with separate tests for C++11, C++14, and C++17.
* testsuite/24_iterators/headers/iterator/range_access_c++11.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++14.cc: New.
* testsuite/24_iterators/headers/iterator/range_access_c++17.cc: New.
From-SVN: r239690
2016-08-23 12:13:12 +02:00
|
|
|
_GLIBCXX17_CONSTEXPR const_pointer
|
2011-05-16 20:09:17 +02:00
|
|
|
data() const noexcept
|
2015-05-28 13:53:35 +02:00
|
|
|
{ return _AT_Type::_S_ptr(_M_elems); }
|
2010-11-02 19:51:23 +01:00
|
|
|
};
|
|
|
|
|
2017-03-22 16:58:35 +01:00
|
|
|
#if __cpp_deduction_guides >= 201606
|
|
|
|
template<typename _Tp, typename... _Up>
|
|
|
|
array(_Tp, _Up...)
|
|
|
|
-> array<enable_if_t<(is_same_v<_Tp, _Up> && ...), _Tp>,
|
|
|
|
1 + sizeof...(_Up)>;
|
|
|
|
#endif
|
|
|
|
|
2010-11-02 19:51:23 +01:00
|
|
|
// Array comparisons.
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in <algorithm> and <utility> Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
none_of, partition_copy, partition_point, remove, remove_if,
remove_copy, remove_copy_if, replace_copy, replace_copy_if,
reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
count_if, equal, find, find_first_of, find_if, for_each, generate,
generate_n, lexicographical_compare, merge, mismatch, replace,
replace_if, search, search_n, set_difference, set_intersection,
set_symmetric_difference, set_union, transform, unique_copy):
Mark constexpr.
* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
* include/bits/predefined_ops.h (_Iter_less_val::operator(),
_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
Use const ref instead of ref arg;
(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
__iter_comp_iter): Mark constexpr.
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Mark constexpr.
* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
wrappers around __builtin_memmove and __builtin_memcmp
respectively;
(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
copy, move, __copy_move_b, __copy_move_backward_a,
__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
__lexicographical_compare_impl, __lexicographical_compare,
__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/constexpr_macro.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite/25_algorithms/count/constexpr.cc: New.
* testsuite/25_algorithms/count_if/constexpr.cc: New.
* testsuite/25_algorithms/equal/constexpr.cc: New.
* testsuite/25_algorithms/equal_range/constexpr.cc: New.
* testsuite/25_algorithms/fill/constexpr.cc: New.
* testsuite/25_algorithms/fill_n/constexpr.cc: New.
* testsuite/25_algorithms/find/constexpr.cc: New.
* testsuite/25_algorithms/find_end/constexpr.cc: New.
* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
* testsuite/25_algorithms/find_if/constexpr.cc: New.
* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
* testsuite/25_algorithms/for_each/constexpr.cc: New.
* testsuite/25_algorithms/generate/constexpr.cc: New.
* testsuite/25_algorithms/generate_n/constexpr.cc: New.
* testsuite/25_algorithms/is_heap/constexpr.cc: New.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
* testsuite/25_algorithms/merge/constexpr.cc: New.
* testsuite/25_algorithms/mismatch/constexpr.cc: New.
* testsuite/25_algorithms/none_of/constexpr.cc: New.
* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
* testsuite/25_algorithms/partition_point/constexpr.cc: New.
* testsuite/25_algorithms/remove/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/remove_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_if/constexpr.cc: New.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
* testsuite/25_algorithms/search/constexpr.cc: New.
* testsuite/25_algorithms/search_n/constexpr.cc: New.
* testsuite/25_algorithms/set_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_union/constexpr.cc: New.
* testsuite/25_algorithms/transform/constexpr.cc: New.
* testsuite/25_algorithms/unique/constexpr.cc: New.
* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
* testsuite/25_algorithms/upper_bound/constexpr.cc: New.
From-SVN: r273975
2019-08-01 17:25:42 +02:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2016-06-16 15:47:35 +02:00
|
|
|
inline bool
|
2010-11-02 19:51:23 +01:00
|
|
|
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
|
|
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
|
|
|
|
|
2019-12-05 01:42:06 +01:00
|
|
|
#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
|
|
|
|
template<typename _Tp, size_t _Nm>
|
|
|
|
constexpr __detail::__synth3way_t<_Tp>
|
|
|
|
operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
|
|
|
|
{
|
2020-09-02 16:17:24 +02:00
|
|
|
#ifdef __cpp_lib_is_constant_evaluated
|
|
|
|
if constexpr (_Nm && __is_memcmp_ordered<_Tp>::__value)
|
|
|
|
if (!std::is_constant_evaluated())
|
|
|
|
{
|
|
|
|
constexpr size_t __n = _Nm * sizeof(_Tp);
|
|
|
|
return __builtin_memcmp(__a.data(), __b.data(), __n) <=> 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (size_t __i = 0; __i < _Nm; ++__i)
|
2019-12-05 01:42:06 +01:00
|
|
|
{
|
2020-09-02 16:17:24 +02:00
|
|
|
auto __c = __detail::__synth3way(__a[__i], __b[__i]);
|
|
|
|
if (__c != 0)
|
|
|
|
return __c;
|
2019-12-05 01:42:06 +01:00
|
|
|
}
|
|
|
|
return strong_ordering::equal;
|
|
|
|
}
|
|
|
|
#else
|
2010-11-02 19:51:23 +01:00
|
|
|
template<typename _Tp, std::size_t _Nm>
|
Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in <algorithm> and <utility> Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
none_of, partition_copy, partition_point, remove, remove_if,
remove_copy, remove_copy_if, replace_copy, replace_copy_if,
reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
count_if, equal, find, find_first_of, find_if, for_each, generate,
generate_n, lexicographical_compare, merge, mismatch, replace,
replace_if, search, search_n, set_difference, set_intersection,
set_symmetric_difference, set_union, transform, unique_copy):
Mark constexpr.
* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
* include/bits/predefined_ops.h (_Iter_less_val::operator(),
_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
Use const ref instead of ref arg;
(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
__iter_comp_iter): Mark constexpr.
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Mark constexpr.
* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
wrappers around __builtin_memmove and __builtin_memcmp
respectively;
(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
copy, move, __copy_move_b, __copy_move_backward_a,
__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
__lexicographical_compare_impl, __lexicographical_compare,
__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/constexpr_macro.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite/25_algorithms/count/constexpr.cc: New.
* testsuite/25_algorithms/count_if/constexpr.cc: New.
* testsuite/25_algorithms/equal/constexpr.cc: New.
* testsuite/25_algorithms/equal_range/constexpr.cc: New.
* testsuite/25_algorithms/fill/constexpr.cc: New.
* testsuite/25_algorithms/fill_n/constexpr.cc: New.
* testsuite/25_algorithms/find/constexpr.cc: New.
* testsuite/25_algorithms/find_end/constexpr.cc: New.
* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
* testsuite/25_algorithms/find_if/constexpr.cc: New.
* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
* testsuite/25_algorithms/for_each/constexpr.cc: New.
* testsuite/25_algorithms/generate/constexpr.cc: New.
* testsuite/25_algorithms/generate_n/constexpr.cc: New.
* testsuite/25_algorithms/is_heap/constexpr.cc: New.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
* testsuite/25_algorithms/merge/constexpr.cc: New.
* testsuite/25_algorithms/mismatch/constexpr.cc: New.
* testsuite/25_algorithms/none_of/constexpr.cc: New.
* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
* testsuite/25_algorithms/partition_point/constexpr.cc: New.
* testsuite/25_algorithms/remove/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/remove_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_if/constexpr.cc: New.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
* testsuite/25_algorithms/search/constexpr.cc: New.
* testsuite/25_algorithms/search_n/constexpr.cc: New.
* testsuite/25_algorithms/set_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_union/constexpr.cc: New.
* testsuite/25_algorithms/transform/constexpr.cc: New.
* testsuite/25_algorithms/unique/constexpr.cc: New.
* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
* testsuite/25_algorithms/upper_bound/constexpr.cc: New.
From-SVN: r273975
2019-08-01 17:25:42 +02:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2010-11-02 19:51:23 +01:00
|
|
|
inline bool
|
|
|
|
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
|
|
{ return !(__one == __two); }
|
|
|
|
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in <algorithm> and <utility> Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
none_of, partition_copy, partition_point, remove, remove_if,
remove_copy, remove_copy_if, replace_copy, replace_copy_if,
reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
count_if, equal, find, find_first_of, find_if, for_each, generate,
generate_n, lexicographical_compare, merge, mismatch, replace,
replace_if, search, search_n, set_difference, set_intersection,
set_symmetric_difference, set_union, transform, unique_copy):
Mark constexpr.
* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
* include/bits/predefined_ops.h (_Iter_less_val::operator(),
_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
Use const ref instead of ref arg;
(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
__iter_comp_iter): Mark constexpr.
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Mark constexpr.
* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
wrappers around __builtin_memmove and __builtin_memcmp
respectively;
(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
copy, move, __copy_move_b, __copy_move_backward_a,
__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
__lexicographical_compare_impl, __lexicographical_compare,
__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/constexpr_macro.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite/25_algorithms/count/constexpr.cc: New.
* testsuite/25_algorithms/count_if/constexpr.cc: New.
* testsuite/25_algorithms/equal/constexpr.cc: New.
* testsuite/25_algorithms/equal_range/constexpr.cc: New.
* testsuite/25_algorithms/fill/constexpr.cc: New.
* testsuite/25_algorithms/fill_n/constexpr.cc: New.
* testsuite/25_algorithms/find/constexpr.cc: New.
* testsuite/25_algorithms/find_end/constexpr.cc: New.
* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
* testsuite/25_algorithms/find_if/constexpr.cc: New.
* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
* testsuite/25_algorithms/for_each/constexpr.cc: New.
* testsuite/25_algorithms/generate/constexpr.cc: New.
* testsuite/25_algorithms/generate_n/constexpr.cc: New.
* testsuite/25_algorithms/is_heap/constexpr.cc: New.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
* testsuite/25_algorithms/merge/constexpr.cc: New.
* testsuite/25_algorithms/mismatch/constexpr.cc: New.
* testsuite/25_algorithms/none_of/constexpr.cc: New.
* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
* testsuite/25_algorithms/partition_point/constexpr.cc: New.
* testsuite/25_algorithms/remove/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/remove_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_if/constexpr.cc: New.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
* testsuite/25_algorithms/search/constexpr.cc: New.
* testsuite/25_algorithms/search_n/constexpr.cc: New.
* testsuite/25_algorithms/set_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_union/constexpr.cc: New.
* testsuite/25_algorithms/transform/constexpr.cc: New.
* testsuite/25_algorithms/unique/constexpr.cc: New.
* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
* testsuite/25_algorithms/upper_bound/constexpr.cc: New.
From-SVN: r273975
2019-08-01 17:25:42 +02:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2010-11-02 19:51:23 +01:00
|
|
|
inline bool
|
|
|
|
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
|
2016-06-16 15:47:35 +02:00
|
|
|
{
|
2010-11-02 19:51:23 +01:00
|
|
|
return std::lexicographical_compare(__a.begin(), __a.end(),
|
2016-06-16 15:47:35 +02:00
|
|
|
__b.begin(), __b.end());
|
2010-11-02 19:51:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in <algorithm> and <utility> Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
none_of, partition_copy, partition_point, remove, remove_if,
remove_copy, remove_copy_if, replace_copy, replace_copy_if,
reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
count_if, equal, find, find_first_of, find_if, for_each, generate,
generate_n, lexicographical_compare, merge, mismatch, replace,
replace_if, search, search_n, set_difference, set_intersection,
set_symmetric_difference, set_union, transform, unique_copy):
Mark constexpr.
* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
* include/bits/predefined_ops.h (_Iter_less_val::operator(),
_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
Use const ref instead of ref arg;
(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
__iter_comp_iter): Mark constexpr.
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Mark constexpr.
* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
wrappers around __builtin_memmove and __builtin_memcmp
respectively;
(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
copy, move, __copy_move_b, __copy_move_backward_a,
__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
__lexicographical_compare_impl, __lexicographical_compare,
__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/constexpr_macro.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite/25_algorithms/count/constexpr.cc: New.
* testsuite/25_algorithms/count_if/constexpr.cc: New.
* testsuite/25_algorithms/equal/constexpr.cc: New.
* testsuite/25_algorithms/equal_range/constexpr.cc: New.
* testsuite/25_algorithms/fill/constexpr.cc: New.
* testsuite/25_algorithms/fill_n/constexpr.cc: New.
* testsuite/25_algorithms/find/constexpr.cc: New.
* testsuite/25_algorithms/find_end/constexpr.cc: New.
* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
* testsuite/25_algorithms/find_if/constexpr.cc: New.
* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
* testsuite/25_algorithms/for_each/constexpr.cc: New.
* testsuite/25_algorithms/generate/constexpr.cc: New.
* testsuite/25_algorithms/generate_n/constexpr.cc: New.
* testsuite/25_algorithms/is_heap/constexpr.cc: New.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
* testsuite/25_algorithms/merge/constexpr.cc: New.
* testsuite/25_algorithms/mismatch/constexpr.cc: New.
* testsuite/25_algorithms/none_of/constexpr.cc: New.
* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
* testsuite/25_algorithms/partition_point/constexpr.cc: New.
* testsuite/25_algorithms/remove/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/remove_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_if/constexpr.cc: New.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
* testsuite/25_algorithms/search/constexpr.cc: New.
* testsuite/25_algorithms/search_n/constexpr.cc: New.
* testsuite/25_algorithms/set_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_union/constexpr.cc: New.
* testsuite/25_algorithms/transform/constexpr.cc: New.
* testsuite/25_algorithms/unique/constexpr.cc: New.
* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
* testsuite/25_algorithms/upper_bound/constexpr.cc: New.
From-SVN: r273975
2019-08-01 17:25:42 +02:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2010-11-02 19:51:23 +01:00
|
|
|
inline bool
|
|
|
|
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
|
|
{ return __two < __one; }
|
|
|
|
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in <algorithm> and <utility> Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
none_of, partition_copy, partition_point, remove, remove_if,
remove_copy, remove_copy_if, replace_copy, replace_copy_if,
reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
count_if, equal, find, find_first_of, find_if, for_each, generate,
generate_n, lexicographical_compare, merge, mismatch, replace,
replace_if, search, search_n, set_difference, set_intersection,
set_symmetric_difference, set_union, transform, unique_copy):
Mark constexpr.
* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
* include/bits/predefined_ops.h (_Iter_less_val::operator(),
_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
Use const ref instead of ref arg;
(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
__iter_comp_iter): Mark constexpr.
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Mark constexpr.
* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
wrappers around __builtin_memmove and __builtin_memcmp
respectively;
(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
copy, move, __copy_move_b, __copy_move_backward_a,
__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
__lexicographical_compare_impl, __lexicographical_compare,
__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/constexpr_macro.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite/25_algorithms/count/constexpr.cc: New.
* testsuite/25_algorithms/count_if/constexpr.cc: New.
* testsuite/25_algorithms/equal/constexpr.cc: New.
* testsuite/25_algorithms/equal_range/constexpr.cc: New.
* testsuite/25_algorithms/fill/constexpr.cc: New.
* testsuite/25_algorithms/fill_n/constexpr.cc: New.
* testsuite/25_algorithms/find/constexpr.cc: New.
* testsuite/25_algorithms/find_end/constexpr.cc: New.
* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
* testsuite/25_algorithms/find_if/constexpr.cc: New.
* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
* testsuite/25_algorithms/for_each/constexpr.cc: New.
* testsuite/25_algorithms/generate/constexpr.cc: New.
* testsuite/25_algorithms/generate_n/constexpr.cc: New.
* testsuite/25_algorithms/is_heap/constexpr.cc: New.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
* testsuite/25_algorithms/merge/constexpr.cc: New.
* testsuite/25_algorithms/mismatch/constexpr.cc: New.
* testsuite/25_algorithms/none_of/constexpr.cc: New.
* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
* testsuite/25_algorithms/partition_point/constexpr.cc: New.
* testsuite/25_algorithms/remove/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/remove_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_if/constexpr.cc: New.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
* testsuite/25_algorithms/search/constexpr.cc: New.
* testsuite/25_algorithms/search_n/constexpr.cc: New.
* testsuite/25_algorithms/set_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_union/constexpr.cc: New.
* testsuite/25_algorithms/transform/constexpr.cc: New.
* testsuite/25_algorithms/unique/constexpr.cc: New.
* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
* testsuite/25_algorithms/upper_bound/constexpr.cc: New.
From-SVN: r273975
2019-08-01 17:25:42 +02:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2010-11-02 19:51:23 +01:00
|
|
|
inline bool
|
|
|
|
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
|
|
{ return !(__one > __two); }
|
|
|
|
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
Implement C++20 p0202 - Add Constexpr Modifiers to Functions in <algorithm> and <utility> Headers.
2019-08-01 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++20 p0202 - Add Constexpr Modifiers to Functions
in <algorithm> and <utility> Headers.
Implement C++20 p1023 - constexpr comparison operators for std::array.
* include/bits/algorithmfwd.h (all_of, any_of, binary_search, copy,
copy_backward, copy_if, copy_n, equal_range, fill, find_end,
find_if_not, includes, is_heap, is_heap_until, is_partitioned,
is_permutation, is_sorted, is_sorted_until, iter_swap, lower_bound,
none_of, partition_copy, partition_point, remove, remove_if,
remove_copy, remove_copy_if, replace_copy, replace_copy_if,
reverse_copy, rotate_copy, uunique, upper_bound, adjacent_find, count,
count_if, equal, find, find_first_of, find_if, for_each, generate,
generate_n, lexicographical_compare, merge, mismatch, replace,
replace_if, search, search_n, set_difference, set_intersection,
set_symmetric_difference, set_union, transform, unique_copy):
Mark constexpr.
* include/bits/cpp_type_traits.h (__miter_base): Mark constexpr.
* include/bits/predefined_ops.h (_Iter_less_val::operator(),
_Val_less_iter::operator(), _Iter_equal_to_iter::operator(),
_Iter_equal_to_val::operator(), _Iter_equals_val::operator()):
Use const ref instead of ref arg;
(_Iter_less_val, __iter_less_val, _Val_less_iter, __val_less_iter,
__iter_equal_to_iter, __iter_equal_to_val, __iter_comp_val,
_Iter_comp_val, _Val_comp_iter, __val_comp_iter, __iter_equals_val,
_Iter_equals_iter, __iter_comp_iter, _Iter_pred, __pred_iter,
_Iter_comp_to_val, __iter_comp_val, _Iter_comp_to_iter,
__iter_comp_iter): Mark constexpr.
* include/bits/stl_algo.h (__find_if, __find_if_not, __find_if_not_n,
__search, __search_n_aux, __search_n, __find_end, find_end, all_of,
none_of, any_of, find_if_not, is_partitioned, partition_point,
__remove_copy_if, remove_copy, remove_copy_if, copy_if, __copy_n,
copy_n, partition_copy, __remove_if, remove, remove_if, __adjacent_find,
__unique, unique, __unique_copy, reverse_copy, rotate_copy,
__unguarded_linear_insert, __insertion_sort, __unguarded_insertion_sort,
__final_insertion_sort, lower_bound, __upper_bound, upper_bound,
__equal_range, equal_range, binary_search, __includes, includes,
__next_permutation, __prev_permutation, __replace_copy_if, replace_copy,
replace_copy_if, __count_if, is_sorted, __is_sorted_until,
is_sorted_until, __is_permutation, is_permutation, for_each, find,
find_if, find_first_of, adjacent_find, count, count_if, search,
search_n, transform, replace, replace_if, generate, generate_n,
unique_copy, __merge, merge, __set_union, set_union, __set_intersection,
set_intersection, __set_difference, set_difference,
__set_symmetric_difference, set_symmetric_difference): Mark constexpr.
* include/bits/stl_algobase.h (__memmove, __memcmp): New maybe constexpr
wrappers around __builtin_memmove and __builtin_memcmp
respectively;
(__niter_base, __niter_wrap, __copy_m, __copy_move_a, __copy_move_a2,
copy, move, __copy_move_b, __copy_move_backward_a,
__copy_move_backward_a2, copy_backward, move_backward, __fill_a, fill,
__fill_n_a, fill_n, equal, __lc_rai::__newlast1, __lc_rai::__cnd2,
__lexicographical_compare_impl, __lexicographical_compare,
__lexicographical_compare<true>::__lc, __lexicographical_compare_aux,
__lower_bound, lower_bound, equal, __equal4, lexicographical_compare,
__mismatch, mismatch, __is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_heap.h (__is_heap_until, __is_heap, is_heap_until,
is_heap): Mark constexpr.
* include/bits/stl_iterator.h (__niter_base, __miter_base): Mark constexpr.
* include/std/array: Make comparison ops constexpr.
* include/std/utility: Make exchange constexpr.
* include/std/version (__cpp_lib_constexpr_algorithms): New macro.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/
tuple_element_neg.cc: Adjust.
* testsuite/20_util/exchange/constexpr.cc: New.
* testsuite/23_containers/array/comparison_operators/constexpr.cc: New.
* testsuite/25_algorithms/constexpr_macro.cc: New.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: New.
* testsuite/25_algorithms/all_of/constexpr.cc: New.
* testsuite/25_algorithms/any_of/constexpr.cc: New.
* testsuite/25_algorithms/binary_search/constexpr.cc: New.
* testsuite/25_algorithms/copy/constexpr.cc: New.
* testsuite/25_algorithms/copy_backward/constexpr.cc: New.
* testsuite/25_algorithms/copy_if/constexpr.cc: New.
* testsuite/25_algorithms/copy_n/constexpr.cc: New.
* testsuite/25_algorithms/count/constexpr.cc: New.
* testsuite/25_algorithms/count_if/constexpr.cc: New.
* testsuite/25_algorithms/equal/constexpr.cc: New.
* testsuite/25_algorithms/equal_range/constexpr.cc: New.
* testsuite/25_algorithms/fill/constexpr.cc: New.
* testsuite/25_algorithms/fill_n/constexpr.cc: New.
* testsuite/25_algorithms/find/constexpr.cc: New.
* testsuite/25_algorithms/find_end/constexpr.cc: New.
* testsuite/25_algorithms/find_first_of/constexpr.cc: New.
* testsuite/25_algorithms/find_if/constexpr.cc: New.
* testsuite/25_algorithms/find_if_not/constexpr.cc: New.
* testsuite/25_algorithms/for_each/constexpr.cc: New.
* testsuite/25_algorithms/generate/constexpr.cc: New.
* testsuite/25_algorithms/generate_n/constexpr.cc: New.
* testsuite/25_algorithms/is_heap/constexpr.cc: New.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: New.
* testsuite/25_algorithms/is_partitioned/constexpr.cc: New.
* testsuite/25_algorithms/is_permutation/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted/constexpr.cc: New.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc: New.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc: New.
* testsuite/25_algorithms/lower_bound/constexpr.cc: New.
* testsuite/25_algorithms/merge/constexpr.cc: New.
* testsuite/25_algorithms/mismatch/constexpr.cc: New.
* testsuite/25_algorithms/none_of/constexpr.cc: New.
* testsuite/25_algorithms/partition_copy/constexpr.cc: New.
* testsuite/25_algorithms/partition_point/constexpr.cc: New.
* testsuite/25_algorithms/remove/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy/constexpr.cc: New.
* testsuite/25_algorithms/remove_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/remove_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy/constexpr.cc: New.
* testsuite/25_algorithms/replace_copy_if/constexpr.cc: New.
* testsuite/25_algorithms/replace_if/constexpr.cc: New.
* testsuite/25_algorithms/reverse_copy/constexpr.cc: New.
* testsuite/25_algorithms/rotate_copy/constexpr.cc: New.
* testsuite/25_algorithms/search/constexpr.cc: New.
* testsuite/25_algorithms/search_n/constexpr.cc: New.
* testsuite/25_algorithms/set_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_intersection/constexpr.cc: New.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: New.
* testsuite/25_algorithms/set_union/constexpr.cc: New.
* testsuite/25_algorithms/transform/constexpr.cc: New.
* testsuite/25_algorithms/unique/constexpr.cc: New.
* testsuite/25_algorithms/unique_copy/constexpr.cc: New.
* testsuite/25_algorithms/upper_bound/constexpr.cc: New.
From-SVN: r273975
2019-08-01 17:25:42 +02:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2010-11-02 19:51:23 +01:00
|
|
|
inline bool
|
|
|
|
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
|
|
|
|
{ return !(__one < __two); }
|
2019-12-05 01:42:06 +01:00
|
|
|
#endif // three_way_comparison && concepts
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2011-05-16 20:09:17 +02:00
|
|
|
// Specialized algorithms.
|
2010-11-02 19:51:23 +01:00
|
|
|
template<typename _Tp, std::size_t _Nm>
|
2019-11-15 01:09:49 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2016-06-16 17:07:19 +02:00
|
|
|
inline
|
|
|
|
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
|
|
|
|
// Constrained free swap overload, see p0185r1
|
|
|
|
typename enable_if<
|
|
|
|
_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value
|
|
|
|
>::type
|
|
|
|
#else
|
|
|
|
void
|
|
|
|
#endif
|
2010-11-02 19:51:23 +01:00
|
|
|
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
|
2011-05-16 20:09:17 +02:00
|
|
|
noexcept(noexcept(__one.swap(__two)))
|
2010-11-02 19:51:23 +01:00
|
|
|
{ __one.swap(__two); }
|
|
|
|
|
Implement LWG 2766,
Swapping non-swappable types and LWG 2749,
swappable traits for variants.
* include/bits/move.h (swap(_Tp&, _Tp&)): Constrain
with __is_tuple_like.
* include/bits/stl_pair.h (swap(pair<_T1, _T2>&, pair<_T1, _T2>&)):
Add a deleted overload.
* include/bits/unique_ptr.h
(swap(unique_ptr<_Tp, _Dp>&, unique_ptr<_Tp, _Dp>&)): Likewise.
* include/std/array
(swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&)): Likewise.
* include/std/optional
(swap(optional<_Tp>&, optional<_Tp>&)): Likewise.
* include/std/tuple (__is_tuple_like_impl, __is_tuple_like):
Move to type_traits.
(swap(tuple<_Elements...>&, tuple<_Elements...>&)): Add a deleted
overload.
* include/std/type_traits (__is_tuple_like_impl, __is_tuple_like):
New.
(swap(_Tp&, _Tp&)): Constrain with __is_tuple_like.
* include/std/utility (__is_tuple_like_impl): Move to type_traits.
* include/std/variant
(swap(variant<_Types...>&, variant<_Types...>&)):
Add a deleted overload.
* testsuite/20_util/optional/swap/2.cc: Add tests for disabled
swaps.
* testsuite/20_util/pair/swap_cxx17.cc: New.
* testsuite/20_util/tuple/swap_cxx17.cc: Likewise.
* testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc:
Likewise.
* testsuite/20_util/variant/compile.cc: Add tests for disabled
swaps.
* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
New.
* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
Likewise.
From-SVN: r243120
2016-12-01 17:23:21 +01:00
|
|
|
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
|
|
|
|
template<typename _Tp, std::size_t _Nm>
|
|
|
|
typename enable_if<
|
|
|
|
!_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type
|
|
|
|
swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete;
|
|
|
|
#endif
|
|
|
|
|
2010-11-02 19:51:23 +01:00
|
|
|
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
2011-09-13 02:06:25 +02:00
|
|
|
constexpr _Tp&
|
2011-05-16 20:09:17 +02:00
|
|
|
get(array<_Tp, _Nm>& __arr) noexcept
|
2012-04-23 14:26:43 +02:00
|
|
|
{
|
2016-07-31 19:08:52 +02:00
|
|
|
static_assert(_Int < _Nm, "array index is within bounds");
|
2012-11-07 01:42:19 +01:00
|
|
|
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
|
|
|
|
_S_ref(__arr._M_elems, _Int);
|
2012-04-23 14:26:43 +02:00
|
|
|
}
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2011-05-16 20:09:17 +02:00
|
|
|
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
2011-09-13 02:06:25 +02:00
|
|
|
constexpr _Tp&&
|
2011-05-16 20:09:17 +02:00
|
|
|
get(array<_Tp, _Nm>&& __arr) noexcept
|
2012-04-23 14:26:43 +02:00
|
|
|
{
|
2016-07-31 19:08:52 +02:00
|
|
|
static_assert(_Int < _Nm, "array index is within bounds");
|
2014-05-13 19:22:08 +02:00
|
|
|
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
|
2012-04-23 14:26:43 +02:00
|
|
|
}
|
2011-05-16 20:09:17 +02:00
|
|
|
|
2010-11-02 19:51:23 +01:00
|
|
|
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
2011-09-13 02:06:25 +02:00
|
|
|
constexpr const _Tp&
|
2011-05-16 20:09:17 +02:00
|
|
|
get(const array<_Tp, _Nm>& __arr) noexcept
|
2012-04-23 14:26:43 +02:00
|
|
|
{
|
2016-07-31 19:08:52 +02:00
|
|
|
static_assert(_Int < _Nm, "array index is within bounds");
|
2012-11-07 01:42:19 +01:00
|
|
|
return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
|
|
|
|
_S_ref(__arr._M_elems, _Int);
|
2012-04-23 14:26:43 +02:00
|
|
|
}
|
2010-11-02 19:51:23 +01:00
|
|
|
|
2017-10-30 15:31:04 +01:00
|
|
|
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
|
|
constexpr const _Tp&&
|
|
|
|
get(const array<_Tp, _Nm>&& __arr) noexcept
|
|
|
|
{
|
|
|
|
static_assert(_Int < _Nm, "array index is within bounds");
|
|
|
|
return std::move(_GLIBCXX_STD_C::get<_Int>(__arr));
|
|
|
|
}
|
|
|
|
|
2019-08-08 12:18:53 +02:00
|
|
|
#if __cplusplus > 201703L
|
|
|
|
#define __cpp_lib_to_array 201907L
|
|
|
|
|
|
|
|
template<bool _Move = false, typename _Tp, size_t... _Idx>
|
|
|
|
constexpr array<remove_cv_t<_Tp>, sizeof...(_Idx)>
|
|
|
|
__to_array(_Tp (&__a)[sizeof...(_Idx)], index_sequence<_Idx...>)
|
|
|
|
{
|
|
|
|
if constexpr (_Move)
|
|
|
|
return {{std::move(__a[_Idx])...}};
|
|
|
|
else
|
|
|
|
return {{__a[_Idx]...}};
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp, size_t _Nm>
|
|
|
|
constexpr array<remove_cv_t<_Tp>, _Nm>
|
|
|
|
to_array(_Tp (&__a)[_Nm])
|
|
|
|
noexcept(is_nothrow_constructible_v<_Tp, _Tp&>)
|
|
|
|
{
|
|
|
|
static_assert(!is_array_v<_Tp>);
|
|
|
|
static_assert(is_constructible_v<_Tp, _Tp&>);
|
|
|
|
if constexpr (is_constructible_v<_Tp, _Tp&>)
|
|
|
|
return _GLIBCXX_STD_C::__to_array(__a, make_index_sequence<_Nm>{});
|
|
|
|
__builtin_unreachable(); // FIXME: see PR c++/91388
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _Tp, size_t _Nm>
|
|
|
|
constexpr array<remove_cv_t<_Tp>, _Nm>
|
|
|
|
to_array(_Tp (&&__a)[_Nm])
|
|
|
|
noexcept(is_nothrow_move_constructible_v<_Tp>)
|
|
|
|
{
|
|
|
|
static_assert(!is_array_v<_Tp>);
|
|
|
|
static_assert(is_move_constructible_v<_Tp>);
|
|
|
|
if constexpr (is_move_constructible_v<_Tp>)
|
|
|
|
return _GLIBCXX_STD_C::__to_array<1>(__a, make_index_sequence<_Nm>{});
|
|
|
|
__builtin_unreachable(); // FIXME: see PR c++/91388
|
|
|
|
}
|
|
|
|
#endif // C++20
|
|
|
|
|
2012-11-07 01:42:19 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_CONTAINER
|
|
|
|
} // namespace std
|
|
|
|
|
2012-11-17 13:09:58 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
|
|
|
|
|
// Tuple interface to class template array.
|
|
|
|
|
|
|
|
/// tuple_size
|
2016-06-16 15:47:35 +02:00
|
|
|
template<typename _Tp>
|
2017-10-25 15:55:56 +02:00
|
|
|
struct tuple_size;
|
2012-11-17 13:09:58 +01:00
|
|
|
|
2014-05-15 12:35:29 +02:00
|
|
|
/// Partial specialization for std::array
|
2012-11-17 13:09:58 +01:00
|
|
|
template<typename _Tp, std::size_t _Nm>
|
|
|
|
struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
|
|
|
|
: public integral_constant<std::size_t, _Nm> { };
|
|
|
|
|
|
|
|
/// tuple_element
|
|
|
|
template<std::size_t _Int, typename _Tp>
|
2017-10-25 15:55:56 +02:00
|
|
|
struct tuple_element;
|
2012-11-17 13:09:58 +01:00
|
|
|
|
2014-05-15 12:35:29 +02:00
|
|
|
/// Partial specialization for std::array
|
2012-11-17 13:09:58 +01:00
|
|
|
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
|
|
|
|
struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
|
|
|
|
{
|
|
|
|
static_assert(_Int < _Nm, "index is out of bounds");
|
|
|
|
typedef _Tp type;
|
|
|
|
};
|
|
|
|
|
2015-06-23 21:51:02 +02:00
|
|
|
template<typename _Tp, std::size_t _Nm>
|
|
|
|
struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type
|
|
|
|
{ };
|
|
|
|
|
2012-11-17 13:09:58 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace std
|
|
|
|
|
2012-11-07 01:42:19 +01:00
|
|
|
#ifdef _GLIBCXX_DEBUG
|
|
|
|
# include <debug/array>
|
|
|
|
#endif
|
|
|
|
|
2012-11-10 18:27:22 +01:00
|
|
|
#endif // C++11
|
2008-05-26 04:19:57 +02:00
|
|
|
|
2008-04-10 21:02:57 +02:00
|
|
|
#endif // _GLIBCXX_ARRAY
|