Apply C++20 changes to various iterator types
This ensures that __normal_iterator<T*, C> satisfies the contiguous_iterator concept, by defining the iterator_concept member type. Also update vector<bool>'s iterators, reverse_iterator, istreambuf_iterator and ostreambuf_iterator to meet the C++20 requirements. PR libstdc++/92272 * include/bits/stl_bvector.h (_Bit_iterator::pointer) (_Bit_const_iterator::pointer): Define as void for C++20. * include/bits/stl_iterator.h (reverse_iterator::operator->()): Add constraints for C++20. (__normal_iterator::iterator_concept): Define for C++20. * include/bits/streambuf_iterator.h (istreambuf_iterator::pointer): Define as void for C++20. (ostreambuf_iterator::difference_type): Define as ptrdiff_t for C++20. (ostreambuf_iterator::ostreambuf_iterator()): Add default constructor for C++20. * testsuite/23_containers/vector/bool/iterator_c++20.cc: New test. * testsuite/24_iterators/bidirectional/concept.cc: New test. * testsuite/24_iterators/bidirectional/tag.cc: New test. * testsuite/24_iterators/contiguous/concept.cc: New test. * testsuite/24_iterators/contiguous/tag.cc: New test. * testsuite/24_iterators/forward/concept.cc: New test. * testsuite/24_iterators/forward/tag.cc: New test. * testsuite/24_iterators/input/concept.cc: New test. * testsuite/24_iterators/input/tag.cc: New test. * testsuite/24_iterators/istreambuf_iterator/requirements/typedefs.cc: New test. * testsuite/24_iterators/ostreambuf_iterator/requirements/typedefs.cc: New test. * testsuite/24_iterators/output/concept.cc: New test. * testsuite/24_iterators/output/tag.cc: New test. * testsuite/24_iterators/random_access/concept.cc: New test. * testsuite/24_iterators/random_access/tag.cc: New test. * testsuite/24_iterators/range_operations/advance_debug_neg.cc: New test. * testsuite/24_iterators/random_access_iterator/26020.cc: Move to ... * testsuite/24_iterators/operations/26020.cc: ... here. * testsuite/24_iterators/random_access_iterator/ string_vector_iterators.cc: Move to ... * testsuite/24_iterators/random_access/string_vector_iterators.cc: ... here. From-SVN: r277629
This commit is contained in:
parent
5211593c58
commit
9aeb3bef2c
22 changed files with 899 additions and 11 deletions
|
@ -1,5 +1,42 @@
|
|||
2019-10-30 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
PR libstdc++/92272
|
||||
* include/bits/stl_bvector.h (_Bit_iterator::pointer)
|
||||
(_Bit_const_iterator::pointer): Define as void for C++20.
|
||||
* include/bits/stl_iterator.h (reverse_iterator::operator->()): Add
|
||||
constraints for C++20.
|
||||
(__normal_iterator::iterator_concept): Define for C++20.
|
||||
* include/bits/streambuf_iterator.h (istreambuf_iterator::pointer):
|
||||
Define as void for C++20.
|
||||
(ostreambuf_iterator::difference_type): Define as ptrdiff_t for C++20.
|
||||
(ostreambuf_iterator::ostreambuf_iterator()): Add default constructor
|
||||
for C++20.
|
||||
* testsuite/23_containers/vector/bool/iterator_c++20.cc: New test.
|
||||
* testsuite/24_iterators/bidirectional/concept.cc: New test.
|
||||
* testsuite/24_iterators/bidirectional/tag.cc: New test.
|
||||
* testsuite/24_iterators/contiguous/concept.cc: New test.
|
||||
* testsuite/24_iterators/contiguous/tag.cc: New test.
|
||||
* testsuite/24_iterators/forward/concept.cc: New test.
|
||||
* testsuite/24_iterators/forward/tag.cc: New test.
|
||||
* testsuite/24_iterators/input/concept.cc: New test.
|
||||
* testsuite/24_iterators/input/tag.cc: New test.
|
||||
* testsuite/24_iterators/istreambuf_iterator/requirements/typedefs.cc:
|
||||
New test.
|
||||
* testsuite/24_iterators/ostreambuf_iterator/requirements/typedefs.cc:
|
||||
New test.
|
||||
* testsuite/24_iterators/output/concept.cc: New test.
|
||||
* testsuite/24_iterators/output/tag.cc: New test.
|
||||
* testsuite/24_iterators/random_access/concept.cc: New test.
|
||||
* testsuite/24_iterators/random_access/tag.cc: New test.
|
||||
* testsuite/24_iterators/range_operations/advance_debug_neg.cc: New
|
||||
test.
|
||||
* testsuite/24_iterators/random_access_iterator/26020.cc: Move to ...
|
||||
* testsuite/24_iterators/operations/26020.cc: ... here.
|
||||
* testsuite/24_iterators/random_access_iterator/
|
||||
string_vector_iterators.cc: Move to ...
|
||||
* testsuite/24_iterators/random_access/string_vector_iterators.cc: ...
|
||||
here.
|
||||
|
||||
* testsuite/util/testsuite_iterators.h: Fix typo in __cplusplus check.
|
||||
|
||||
2019-10-29 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
|
|
@ -220,7 +220,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
struct _Bit_iterator : public _Bit_iterator_base
|
||||
{
|
||||
typedef _Bit_reference reference;
|
||||
#if __cplusplus > 201703L
|
||||
typedef void pointer;
|
||||
#else
|
||||
typedef _Bit_reference* pointer;
|
||||
#endif
|
||||
typedef _Bit_iterator iterator;
|
||||
|
||||
_Bit_iterator() : _Bit_iterator_base(0, 0) { }
|
||||
|
@ -309,7 +313,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
{
|
||||
typedef bool reference;
|
||||
typedef bool const_reference;
|
||||
#if __cplusplus > 201703L
|
||||
typedef void pointer;
|
||||
#else
|
||||
typedef const bool* pointer;
|
||||
#endif
|
||||
typedef _Bit_const_iterator const_iterator;
|
||||
|
||||
_Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
|
||||
|
|
|
@ -187,6 +187,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
*/
|
||||
_GLIBCXX17_CONSTEXPR pointer
|
||||
operator->() const
|
||||
#if __cplusplus > 201703L && defined __cpp_concepts
|
||||
requires is_pointer_v<_Iterator>
|
||||
|| requires(const _Iterator __i) { __i.operator->(); }
|
||||
#endif
|
||||
{
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 1052. operator-> should also support smart pointers
|
||||
|
@ -807,6 +811,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
typedef typename __traits_type::reference reference;
|
||||
typedef typename __traits_type::pointer pointer;
|
||||
|
||||
#if __cplusplus > 201703L
|
||||
using iterator_concept = std::__detail::__iter_concept<_Iterator>;
|
||||
#endif
|
||||
|
||||
_GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
|
||||
: _M_current(_Iterator()) { }
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
// Types:
|
||||
//@{
|
||||
/// Public typedefs
|
||||
#if __cplusplus > 201703L
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 3188. istreambuf_iterator::pointer should not be unspecified
|
||||
using pointer = void;
|
||||
#endif
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef typename _Traits::int_type int_type;
|
||||
|
@ -230,6 +235,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
// Types:
|
||||
//@{
|
||||
/// Public typedefs
|
||||
#if __cplusplus > 201703L
|
||||
using difference_type = ptrdiff_t;
|
||||
#endif
|
||||
typedef _CharT char_type;
|
||||
typedef _Traits traits_type;
|
||||
typedef basic_streambuf<_CharT, _Traits> streambuf_type;
|
||||
|
@ -247,6 +255,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
bool _M_failed;
|
||||
|
||||
public:
|
||||
|
||||
#if __cplusplus > 201703L
|
||||
constexpr
|
||||
ostreambuf_iterator() noexcept
|
||||
: _M_sbuf(nullptr), _M_failed(true) { }
|
||||
#endif
|
||||
|
||||
/// Construct output iterator from ostream.
|
||||
ostreambuf_iterator(ostream_type& __s) _GLIBCXX_USE_NOEXCEPT
|
||||
: _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
#include <vector>
|
||||
|
||||
// C++20 [iterator.traits]: The type iterator_traits<I>::pointer shall be void
|
||||
// for an iterator of class type I that does not support operator->.
|
||||
template<typename I>
|
||||
concept arrow_or_no_pointer = requires (I i) { i.operator->(); }
|
||||
|| std::same_as<typename std::iterator_traits<I>::pointer, void>;
|
||||
|
||||
static_assert( arrow_or_no_pointer<std::vector<bool>::iterator> );
|
||||
static_assert( arrow_or_no_pointer<std::vector<bool>::const_iterator> );
|
81
libstdc++-v3/testsuite/24_iterators/bidirectional/concept.cc
Normal file
81
libstdc++-v3/testsuite/24_iterators/bidirectional/concept.cc
Normal file
|
@ -0,0 +1,81 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::bidirectional_iterator;
|
||||
|
||||
static_assert( bidirectional_iterator< int* > );
|
||||
static_assert( bidirectional_iterator< const int* > );
|
||||
static_assert( bidirectional_iterator< void** > );
|
||||
|
||||
static_assert( ! bidirectional_iterator< int* const > );
|
||||
static_assert( ! bidirectional_iterator< const int* const > );
|
||||
static_assert( ! bidirectional_iterator< void** const > );
|
||||
|
||||
static_assert( ! bidirectional_iterator< void* > );
|
||||
static_assert( ! bidirectional_iterator< const void* > );
|
||||
static_assert( ! bidirectional_iterator< volatile void* > );
|
||||
|
||||
static_assert( ! bidirectional_iterator< void(*)() > );
|
||||
static_assert( ! bidirectional_iterator< void(&)() > );
|
||||
|
||||
struct A;
|
||||
static_assert( ! bidirectional_iterator< void(A::*)() > );
|
||||
static_assert( ! bidirectional_iterator< int A::* > );
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::forward_list;
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
|
||||
struct B { };
|
||||
|
||||
static_assert( bidirectional_iterator< array<int, 1>::iterator > );
|
||||
static_assert( bidirectional_iterator< array<B, 1>::const_iterator > );
|
||||
|
||||
static_assert( bidirectional_iterator< deque<int>::iterator > );
|
||||
static_assert( bidirectional_iterator< deque<B>::const_iterator > );
|
||||
|
||||
static_assert( bidirectional_iterator< list<int>::iterator > );
|
||||
static_assert( bidirectional_iterator< list<B>::const_iterator > );
|
||||
|
||||
static_assert( ! bidirectional_iterator< forward_list<int>::iterator > );
|
||||
static_assert( ! bidirectional_iterator< forward_list<B>::const_iterator > );
|
||||
|
||||
static_assert( bidirectional_iterator< string::iterator > );
|
||||
static_assert( bidirectional_iterator< string::const_iterator > );
|
||||
|
||||
static_assert( bidirectional_iterator< string_view::iterator > );
|
||||
static_assert( bidirectional_iterator< string_view::const_iterator > );
|
||||
|
||||
static_assert( bidirectional_iterator< vector<int>::iterator > );
|
||||
static_assert( bidirectional_iterator< vector<B>::const_iterator > );
|
32
libstdc++-v3/testsuite/24_iterators/bidirectional/tag.cc
Normal file
32
libstdc++-v3/testsuite/24_iterators/bidirectional/tag.cc
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::bidirectional_iterator_tag;
|
||||
using std::forward_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
static_assert( std::is_empty<bidirectional_iterator_tag>::value );
|
||||
static_assert( std::is_trivially_copy_constructible<bidirectional_iterator_tag>::value );
|
||||
|
||||
static_assert( std::is_base_of<forward_iterator_tag,
|
||||
bidirectional_iterator_tag>::value );
|
||||
static_assert( std::is_convertible<bidirectional_iterator_tag*,
|
||||
forward_iterator_tag*>::value );
|
|
@ -20,17 +20,61 @@
|
|||
|
||||
#include <iterator>
|
||||
|
||||
static_assert( std::contiguous_iterator<int*> );
|
||||
static_assert( std::contiguous_iterator<const int*> );
|
||||
static_assert( std::contiguous_iterator<void**> );
|
||||
using std::contiguous_iterator;
|
||||
|
||||
static_assert( ! std::contiguous_iterator<void*> );
|
||||
static_assert( ! std::contiguous_iterator<const void*> );
|
||||
static_assert( ! std::contiguous_iterator<volatile void*> );
|
||||
static_assert( contiguous_iterator< int* > );
|
||||
static_assert( contiguous_iterator< const int* > );
|
||||
static_assert( contiguous_iterator< void** > );
|
||||
|
||||
static_assert( ! std::contiguous_iterator<void(*)()> );
|
||||
static_assert( ! std::contiguous_iterator<void(*)()> );
|
||||
static_assert( ! contiguous_iterator< int* const > );
|
||||
static_assert( ! contiguous_iterator< const int* const > );
|
||||
static_assert( ! contiguous_iterator< void** const > );
|
||||
|
||||
static_assert( ! contiguous_iterator< void* > );
|
||||
static_assert( ! contiguous_iterator< const void* > );
|
||||
static_assert( ! contiguous_iterator< volatile void* > );
|
||||
|
||||
static_assert( ! contiguous_iterator< void(*)() > );
|
||||
static_assert( ! contiguous_iterator< void(&)() > );
|
||||
static_assert( contiguous_iterator< void(**)() > );
|
||||
|
||||
struct A;
|
||||
static_assert( ! std::contiguous_iterator<void(A::*)()> );
|
||||
static_assert( ! std::contiguous_iterator<int A::*> );
|
||||
static_assert( ! contiguous_iterator< void(A::*)() > );
|
||||
static_assert( ! contiguous_iterator< int A::* > );
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
|
||||
struct B { };
|
||||
|
||||
static_assert( contiguous_iterator< array<int, 1>::iterator > );
|
||||
static_assert( contiguous_iterator< array<B, 1>::const_iterator > );
|
||||
|
||||
static_assert( ! contiguous_iterator< deque<int>::iterator > );
|
||||
static_assert( ! contiguous_iterator< deque<B>::const_iterator > );
|
||||
|
||||
static_assert( ! contiguous_iterator< list<int>::iterator > );
|
||||
static_assert( ! contiguous_iterator< list<B>::const_iterator > );
|
||||
|
||||
static_assert( contiguous_iterator< string::iterator > );
|
||||
static_assert( contiguous_iterator< string::const_iterator > );
|
||||
|
||||
static_assert( contiguous_iterator< string_view::iterator > );
|
||||
static_assert( contiguous_iterator< string_view::const_iterator > );
|
||||
|
||||
static_assert( contiguous_iterator< vector<int>::iterator > );
|
||||
static_assert( contiguous_iterator< vector<B>::const_iterator > );
|
||||
|
||||
static_assert( ! contiguous_iterator< vector<bool>::iterator > );
|
||||
static_assert( ! contiguous_iterator< vector<bool>::const_iterator > );
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
|
||||
#include <iterator>
|
||||
|
||||
using std::contiguous_iterator_tag;
|
||||
using std::random_access_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
static_assert( std::is_empty_v<std::contiguous_iterator_tag> );
|
||||
static_assert( std::is_trivially_copy_constructible_v<std::contiguous_iterator_tag> );
|
||||
|
||||
|
|
86
libstdc++-v3/testsuite/24_iterators/forward/concept.cc
Normal file
86
libstdc++-v3/testsuite/24_iterators/forward/concept.cc
Normal file
|
@ -0,0 +1,86 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::forward_iterator;
|
||||
|
||||
static_assert( forward_iterator< int* > );
|
||||
static_assert( forward_iterator< const int* > );
|
||||
static_assert( forward_iterator< void** > );
|
||||
|
||||
static_assert( ! forward_iterator< int* const > );
|
||||
static_assert( ! forward_iterator< const int* const > );
|
||||
static_assert( ! forward_iterator< void** const > );
|
||||
|
||||
static_assert( ! forward_iterator< void* > );
|
||||
static_assert( ! forward_iterator< const void* > );
|
||||
static_assert( ! forward_iterator< volatile void* > );
|
||||
|
||||
static_assert( ! forward_iterator< void(*)() > );
|
||||
static_assert( ! forward_iterator< void(&)() > );
|
||||
|
||||
struct A;
|
||||
static_assert( ! forward_iterator< void(A::*)() > );
|
||||
static_assert( ! forward_iterator< int A::* > );
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::forward_list;
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
using std::istreambuf_iterator;
|
||||
using std::ostreambuf_iterator;
|
||||
|
||||
struct B { };
|
||||
|
||||
static_assert( forward_iterator< array<int, 1>::iterator > );
|
||||
static_assert( forward_iterator< array<B, 1>::const_iterator > );
|
||||
|
||||
static_assert( forward_iterator< deque<int>::iterator > );
|
||||
static_assert( forward_iterator< deque<B>::const_iterator > );
|
||||
|
||||
static_assert( forward_iterator< forward_list<int>::iterator > );
|
||||
static_assert( forward_iterator< forward_list<B>::const_iterator > );
|
||||
|
||||
static_assert( forward_iterator< list<int>::iterator > );
|
||||
static_assert( forward_iterator< list<B>::const_iterator > );
|
||||
|
||||
static_assert( forward_iterator< string::iterator > );
|
||||
static_assert( forward_iterator< string::const_iterator > );
|
||||
|
||||
static_assert( forward_iterator< string_view::iterator > );
|
||||
static_assert( forward_iterator< string_view::const_iterator > );
|
||||
|
||||
static_assert( forward_iterator< vector<int>::iterator > );
|
||||
static_assert( forward_iterator< vector<B>::const_iterator > );
|
||||
|
||||
static_assert( ! forward_iterator< istreambuf_iterator<char> > );
|
||||
static_assert( ! forward_iterator< ostreambuf_iterator<char> > );
|
32
libstdc++-v3/testsuite/24_iterators/forward/tag.cc
Normal file
32
libstdc++-v3/testsuite/24_iterators/forward/tag.cc
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::forward_iterator_tag;
|
||||
using std::input_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
static_assert( std::is_empty<forward_iterator_tag>::value );
|
||||
static_assert( std::is_trivially_copy_constructible<forward_iterator_tag>::value );
|
||||
|
||||
static_assert( std::is_base_of<input_iterator_tag,
|
||||
forward_iterator_tag>::value );
|
||||
static_assert( std::is_convertible<forward_iterator_tag*,
|
||||
input_iterator_tag*>::value );
|
89
libstdc++-v3/testsuite/24_iterators/input/concept.cc
Normal file
89
libstdc++-v3/testsuite/24_iterators/input/concept.cc
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::input_iterator;
|
||||
|
||||
static_assert( input_iterator< int* > );
|
||||
static_assert( input_iterator< const int* > );
|
||||
static_assert( input_iterator< void** > );
|
||||
|
||||
static_assert( ! input_iterator< int* const > );
|
||||
static_assert( ! input_iterator< const int* const > );
|
||||
static_assert( ! input_iterator< void** const > );
|
||||
|
||||
static_assert( ! input_iterator< void* > );
|
||||
static_assert( ! input_iterator< const void* > );
|
||||
static_assert( ! input_iterator< volatile void* > );
|
||||
|
||||
static_assert( ! input_iterator< void(*)() > );
|
||||
static_assert( ! input_iterator< void(&)() > );
|
||||
|
||||
struct A;
|
||||
static_assert( ! input_iterator< void(A::*)() > );
|
||||
static_assert( ! input_iterator< int A::* > );
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::forward_list;
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
|
||||
struct B { };
|
||||
|
||||
static_assert( input_iterator< array<int, 1>::iterator > );
|
||||
static_assert( input_iterator< array<B, 1>::const_iterator > );
|
||||
|
||||
static_assert( input_iterator< deque<int>::iterator > );
|
||||
static_assert( input_iterator< deque<B>::const_iterator > );
|
||||
|
||||
static_assert( input_iterator< forward_list<int>::iterator > );
|
||||
static_assert( input_iterator< forward_list<B>::const_iterator > );
|
||||
|
||||
static_assert( input_iterator< list<int>::iterator > );
|
||||
static_assert( input_iterator< list<B>::const_iterator > );
|
||||
|
||||
static_assert( input_iterator< string::iterator > );
|
||||
static_assert( input_iterator< string::const_iterator > );
|
||||
|
||||
static_assert( input_iterator< string_view::iterator > );
|
||||
static_assert( input_iterator< string_view::const_iterator > );
|
||||
|
||||
static_assert( input_iterator< vector<int>::iterator > );
|
||||
static_assert( input_iterator< vector<B>::const_iterator > );
|
||||
|
||||
#include <streambuf>
|
||||
|
||||
using std::istreambuf_iterator;
|
||||
using std::ostreambuf_iterator;
|
||||
|
||||
static_assert( input_iterator< istreambuf_iterator<char> > );
|
||||
static_assert( ! input_iterator< ostreambuf_iterator<char> > );
|
32
libstdc++-v3/testsuite/24_iterators/input/tag.cc
Normal file
32
libstdc++-v3/testsuite/24_iterators/input/tag.cc
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::input_iterator_tag;
|
||||
using std::output_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
static_assert( std::is_empty<input_iterator_tag>::value );
|
||||
static_assert( std::is_trivially_copy_constructible<input_iterator_tag>::value );
|
||||
|
||||
static_assert( ! std::is_base_of<output_iterator_tag,
|
||||
input_iterator_tag>::value );
|
||||
static_assert( ! std::is_convertible<input_iterator_tag*,
|
||||
output_iterator_tag*>::value );
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
|
@ -41,3 +40,53 @@ void test01()
|
|||
typedef test_iterator::istream_type istream_type;
|
||||
typedef test_iterator::streambuf_type streambuf_type;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
void test02()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
using test_type = istreambuf_iterator<char>;
|
||||
|
||||
static_assert(is_same<test_type::value_type, char>::value, "");
|
||||
static_assert(is_same<test_type::difference_type,
|
||||
char_traits<char>::off_type>::value, "");
|
||||
#if __cplusplus <= 201703L
|
||||
static_assert(is_same<test_type::pointer, char*>::value, "");
|
||||
#else
|
||||
static_assert(is_same<test_type::pointer, void>::value, "");
|
||||
#endif
|
||||
static_assert(is_same<test_type::reference, char>::value, "");
|
||||
static_assert(is_same<test_type::iterator_category, input_iterator_tag>::value, "");
|
||||
|
||||
static_assert(is_same<test_type::char_type, char>::value, "");
|
||||
static_assert(is_same<test_type::traits_type, char_traits<char>>::value, "");
|
||||
static_assert(is_same<test_type::istream_type, istream>::value, "");
|
||||
static_assert(is_same<test_type::streambuf_type, streambuf>::value, "");
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
void test03()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
using test_type = istreambuf_iterator<wchar_t>;
|
||||
|
||||
static_assert(is_same<test_type::value_type, wchar_t>::value, "");
|
||||
static_assert(is_same<test_type::difference_type,
|
||||
char_traits<wchar_t>::off_type>::value, "");
|
||||
#if __cplusplus <= 201703L
|
||||
static_assert(is_same<test_type::pointer, wchar_t*>::value, "");
|
||||
#else
|
||||
static_assert(is_same<test_type::pointer, void>::value, "");
|
||||
#endif
|
||||
static_assert(is_same<test_type::reference, wchar_t>::value, "");
|
||||
static_assert(is_same<test_type::iterator_category, input_iterator_tag>::value, "");
|
||||
|
||||
static_assert(is_same<test_type::char_type, wchar_t>::value, "");
|
||||
static_assert(is_same<test_type::traits_type, char_traits<wchar_t>>::value, "");
|
||||
static_assert(is_same<test_type::istream_type, wistream>::value, "");
|
||||
static_assert(is_same<test_type::streambuf_type, wstreambuf>::value, "");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -41,3 +41,49 @@ void test01()
|
|||
typedef test_iterator::ostream_type ostream_type;
|
||||
typedef test_iterator::streambuf_type streambuf_type;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
void test02()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
using test_type = ostreambuf_iterator<char>;
|
||||
static_assert(is_same<test_type::value_type, void>::value, "");
|
||||
#if __cplusplus <= 201703L
|
||||
static_assert(is_same<test_type::difference_type, void>::value, "");
|
||||
#else
|
||||
static_assert(is_same<test_type::difference_type, ptrdiff_t>::value, "");
|
||||
#endif
|
||||
static_assert(is_same<test_type::pointer, void>::value, "");
|
||||
static_assert(is_same<test_type::reference, void>::value, "");
|
||||
static_assert(is_same<test_type::iterator_category, output_iterator_tag>::value, "");
|
||||
|
||||
static_assert(is_same<test_type::char_type, char>::value, "");
|
||||
static_assert(is_same<test_type::traits_type, char_traits<char>>::value, "");
|
||||
static_assert(is_same<test_type::ostream_type, ostream>::value, "");
|
||||
static_assert(is_same<test_type::streambuf_type, streambuf>::value, "");
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
void test03()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
using test_type = ostreambuf_iterator<wchar_t>;
|
||||
static_assert(is_same<test_type::value_type, void>::value, "");
|
||||
#if __cplusplus <= 201703L
|
||||
static_assert(is_same<test_type::difference_type, void>::value, "");
|
||||
#else
|
||||
static_assert(is_same<test_type::difference_type, ptrdiff_t>::value, "");
|
||||
#endif
|
||||
static_assert(is_same<test_type::pointer, void>::value, "");
|
||||
static_assert(is_same<test_type::reference, void>::value, "");
|
||||
static_assert(is_same<test_type::iterator_category, output_iterator_tag>::value, "");
|
||||
|
||||
static_assert(is_same<test_type::char_type, wchar_t>::value, "");
|
||||
static_assert(is_same<test_type::traits_type, char_traits<wchar_t>>::value, "");
|
||||
static_assert(is_same<test_type::ostream_type, wostream>::value, "");
|
||||
static_assert(is_same<test_type::streambuf_type, wstreambuf>::value, "");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
121
libstdc++-v3/testsuite/24_iterators/output/concept.cc
Normal file
121
libstdc++-v3/testsuite/24_iterators/output/concept.cc
Normal file
|
@ -0,0 +1,121 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::output_iterator;
|
||||
|
||||
static_assert( output_iterator< int*, int > );
|
||||
static_assert( output_iterator< int*, const int > );
|
||||
static_assert( output_iterator< int*, long > );
|
||||
static_assert( output_iterator< void**, void* > );
|
||||
static_assert( output_iterator< void**, long* > );
|
||||
static_assert( ! output_iterator< const int*, int > );
|
||||
|
||||
static_assert( ! output_iterator< int* const, int > );
|
||||
static_assert( ! output_iterator< const int* const, int > );
|
||||
static_assert( ! output_iterator< void** const, void* > );
|
||||
|
||||
static_assert( ! output_iterator< void*, void > );
|
||||
static_assert( ! output_iterator< const void*, void > );
|
||||
static_assert( ! output_iterator< const void*, void* > );
|
||||
static_assert( ! output_iterator< volatile void*, void > );
|
||||
static_assert( ! output_iterator< volatile void*, void* > );
|
||||
|
||||
static_assert( ! output_iterator< void(*)(), void(&)() > );
|
||||
static_assert( ! output_iterator< void(&)(), void(&)() > );
|
||||
static_assert( output_iterator< void(**)(), void(*)() > );
|
||||
static_assert( output_iterator< void(**)(), void(&)() > );
|
||||
|
||||
struct A;
|
||||
static_assert( ! output_iterator< void(A::*)(), A* > );
|
||||
static_assert( ! output_iterator< void(A::*)(), void(A::*)() > );
|
||||
static_assert( ! output_iterator< int A::*, int > );
|
||||
static_assert( ! output_iterator< int A::*, int A::* > );
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::forward_list;
|
||||
using std::list;
|
||||
using std::set;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
|
||||
struct B { };
|
||||
|
||||
static_assert( output_iterator< array<int, 1>::iterator, int > );
|
||||
static_assert( output_iterator< array<B, 1>::iterator, B > );
|
||||
static_assert( ! output_iterator< array<int, 1>::const_iterator, int > );
|
||||
static_assert( ! output_iterator< array<B, 1>::const_iterator, B > );
|
||||
|
||||
static_assert( output_iterator< deque<int>::iterator, int > );
|
||||
static_assert( output_iterator< deque<B>::iterator, B > );
|
||||
static_assert( ! output_iterator< deque<int>::const_iterator, int > );
|
||||
static_assert( ! output_iterator< deque<B>::const_iterator, B > );
|
||||
|
||||
static_assert( output_iterator< forward_list<int>::iterator, int > );
|
||||
static_assert( output_iterator< forward_list<B>::iterator, B > );
|
||||
static_assert( ! output_iterator< forward_list<int>::const_iterator, int > );
|
||||
static_assert( ! output_iterator< forward_list<B>::const_iterator, B > );
|
||||
|
||||
static_assert( output_iterator< list<int>::iterator, int > );
|
||||
static_assert( output_iterator< list<B>::iterator, B > );
|
||||
static_assert( ! output_iterator< list<int>::const_iterator, int > );
|
||||
static_assert( ! output_iterator< list<B>::const_iterator, B > );
|
||||
|
||||
static_assert( ! output_iterator< set<int>::iterator, int > );
|
||||
static_assert( ! output_iterator< set<B>::iterator, B > );
|
||||
static_assert( ! output_iterator< set<int>::const_iterator, int > );
|
||||
static_assert( ! output_iterator< set<B>::const_iterator, B > );
|
||||
|
||||
static_assert( output_iterator< string::iterator, char > );
|
||||
static_assert( output_iterator< string::iterator, int > );
|
||||
static_assert( ! output_iterator< string::const_iterator, char > );
|
||||
static_assert( ! output_iterator< string::const_iterator, int > );
|
||||
|
||||
static_assert( ! output_iterator< string_view::iterator, char > );
|
||||
static_assert( ! output_iterator< string_view::iterator, int > );
|
||||
static_assert( ! output_iterator< string_view::const_iterator, char > );
|
||||
static_assert( ! output_iterator< string_view::const_iterator, int > );
|
||||
|
||||
static_assert( output_iterator< vector<int>::iterator, int > );
|
||||
static_assert( output_iterator< vector<B>::iterator, B > );
|
||||
static_assert( ! output_iterator< vector<int>::const_iterator, int > );
|
||||
static_assert( ! output_iterator< vector<B>::const_iterator, B > );
|
||||
|
||||
#include <streambuf>
|
||||
|
||||
using std::istreambuf_iterator;
|
||||
using std::ostreambuf_iterator;
|
||||
|
||||
static_assert( ! output_iterator< istreambuf_iterator<char>, char > );
|
||||
static_assert( ! output_iterator< istreambuf_iterator<char>, int > );
|
||||
static_assert( output_iterator< ostreambuf_iterator<char>, char > );
|
||||
static_assert( output_iterator< ostreambuf_iterator<char>, int > );
|
32
libstdc++-v3/testsuite/24_iterators/output/tag.cc
Normal file
32
libstdc++-v3/testsuite/24_iterators/output/tag.cc
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::output_iterator_tag;
|
||||
using std::input_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
static_assert( std::is_empty<output_iterator_tag>::value );
|
||||
static_assert( std::is_trivially_copy_constructible<output_iterator_tag>::value );
|
||||
|
||||
static_assert( ! std::is_base_of<input_iterator_tag,
|
||||
output_iterator_tag>::value );
|
||||
static_assert( ! std::is_convertible<output_iterator_tag*,
|
||||
input_iterator_tag*>::value );
|
76
libstdc++-v3/testsuite/24_iterators/random_access/concept.cc
Normal file
76
libstdc++-v3/testsuite/24_iterators/random_access/concept.cc
Normal file
|
@ -0,0 +1,76 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a" }
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::random_access_iterator;
|
||||
|
||||
static_assert( random_access_iterator< int* > );
|
||||
static_assert( random_access_iterator< const int* > );
|
||||
static_assert( random_access_iterator< void** > );
|
||||
|
||||
static_assert( ! random_access_iterator< int* const > );
|
||||
static_assert( ! random_access_iterator< const int* const > );
|
||||
static_assert( ! random_access_iterator< void** const > );
|
||||
|
||||
static_assert( ! random_access_iterator< void* > );
|
||||
static_assert( ! random_access_iterator< const void* > );
|
||||
static_assert( ! random_access_iterator< volatile void* > );
|
||||
|
||||
static_assert( ! random_access_iterator< void(*)() > );
|
||||
static_assert( ! random_access_iterator< void(&)() > );
|
||||
|
||||
struct A;
|
||||
static_assert( ! random_access_iterator< void(A::*)() > );
|
||||
static_assert( ! random_access_iterator< int A::* > );
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::list;
|
||||
using std::string;
|
||||
using std::string_view;
|
||||
using std::vector;
|
||||
|
||||
struct B { };
|
||||
|
||||
static_assert( random_access_iterator< array<int, 1>::iterator > );
|
||||
static_assert( random_access_iterator< array<B, 1>::const_iterator > );
|
||||
|
||||
static_assert( random_access_iterator< deque<int>::iterator > );
|
||||
static_assert( random_access_iterator< deque<B>::const_iterator > );
|
||||
|
||||
static_assert( ! random_access_iterator< list<int>::iterator > );
|
||||
static_assert( ! random_access_iterator< list<B>::const_iterator > );
|
||||
|
||||
static_assert( random_access_iterator< string::iterator > );
|
||||
static_assert( random_access_iterator< string::const_iterator > );
|
||||
|
||||
static_assert( random_access_iterator< string_view::iterator > );
|
||||
static_assert( random_access_iterator< string_view::const_iterator > );
|
||||
|
||||
static_assert( random_access_iterator< vector<int>::iterator > );
|
||||
static_assert( random_access_iterator< vector<B>::const_iterator > );
|
35
libstdc++-v3/testsuite/24_iterators/random_access/tag.cc
Normal file
35
libstdc++-v3/testsuite/24_iterators/random_access/tag.cc
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
#include <iterator>
|
||||
|
||||
using std::random_access_iterator_tag;
|
||||
using std::bidirectional_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
static_assert( std::is_empty<random_access_iterator_tag>::value );
|
||||
static_assert( std::is_trivially_copy_constructible<random_access_iterator_tag>::value );
|
||||
|
||||
static_assert( std::is_base_of<bidirectional_iterator_tag,
|
||||
random_access_iterator_tag>::value );
|
||||
static_assert( std::is_convertible<random_access_iterator_tag*,
|
||||
bidirectional_iterator_tag*>::value );
|
||||
|
||||
static_assert( std::is_same<iterator_traits<int*>::iterator_category,
|
||||
random_access_iterator_tag>::value );
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
//
|
||||
// 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
|
||||
// Free Software Foundation; either version 3, or (at your option)
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING3. If not see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-options "-std=gnu++2a -D_GLIBCXX_DEBUG" }
|
||||
// { dg-do compile { xfail c++2a } }
|
||||
|
||||
#include <iterator>
|
||||
#include <testsuite_iterators.h>
|
||||
|
||||
void
|
||||
test01()
|
||||
{
|
||||
int a[2] = { };
|
||||
__gnu_test::test_container<int, __gnu_test::forward_iterator_wrapper> c(a);
|
||||
auto iter = c.begin();
|
||||
std::ranges::advance(iter, -1);
|
||||
}
|
Loading…
Add table
Reference in a new issue