0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

24.7 Views [views] C++N4910:2022 (643) p960.cpp

Last updated at Posted at 2022-08-08

はじめに(Introduction)

N4910 Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf

n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 WG21では、可能な限り作業文書を公開し、幅広い意見を求めています。
一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, TOPPERSカーネル、g++(GCC), clang++(LLVM)との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。

<この項は書きかけです。順次追記します。>

背景(back ground)

C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに1回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。

この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を10種類以上、最近になって解決できたことがあります。それは、主に次の3つの情報に基づいています。

cpprefjp - C++日本語リファレンス

コンパイラの実装状況

また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。

作業方針(sequence)

Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの2種類
でコンパイルし、

1)コンパイルエラーを収集する。
2)コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
3)リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
4)意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。

1)だけのものから4)まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。

C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list

C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list

C++N4606, 2016符号断片編纂一覧(example code compile list)

C++N4606, 2016 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

C++N3242, 2011 sample code compile list on clang++ and g++

編纂器(Compiler)

clang++ --version

Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
Target: x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin

g++- --version

g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

24.7 Views [views] C++N4910:2022 (643) p960.cpp

算譜(source code)

p960.cpp
// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "24.7 Views [views] C++N4910:2022 (643) p960.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. OGAWA Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

#include "N4910.h"

using namespace std;

//  24.7.1 General [views.general]
// The header <span> defines the view span.
// 24.7.2 Header <span> synopsis [span.syn]
namespace std {
// constants
inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
// 24.7.3, class template span
template<class ElementType, size_t Extent = dynamic_extent>
class span;
template<class ElementType, size_t Extent>
inline constexpr bool ranges::enable_view<span<ElementType, Extent>> = true;
template<class ElementType, size_t Extent>
inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
// 24.7.3.8, views of object representation template<class ElementType, size_t Extent>
span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
as_bytes(span<ElementType, Extent> s) noexcept;
template<class ElementType, size_t Extent>
span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
as_writable_bytes(span<ElementType, Extent> s) noexcept;
}
// 24.7.3 Class template span [views.span]
// 24.7.3.1 Overview [span.overview]
// A span is a view over a contiguous sequence of objects, the storage of which is owned by some other object.
//  All member functions of span have constant time complexity.
namespace std {
template<class ElementType, size_t Extent = dynamic_extent>
class span {
public:
// constants and types
    using element_type = ElementType;
    using value_type = remove_cv_t<ElementType>;
    using size_type = size_t;
    using difference_type = ptrdiff_t;
    using pointer = element_type*;
    using const_pointer = const element_type*;
    using reference = element_type&;
    using const_reference = const element_type&;
    using iterator = implementation_defined ;
    using reverse_iterator = std::reverse_iterator<iterator>;
    static constexpr size_type extent = Extent;
// 24.7.3.2, constructors, copy, and assignment constexpr span() noexcept;
    template<class It>
    constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
    template<class It, class End>
    constexpr explicit(extent != dynamic_extent) span(It first, End last);
    template<size_t N>
    constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
    template<class T, size_t N>
    constexpr span(array<T, N>& arr) noexcept;
    template<class T, size_t N>
    constexpr span(const array<T, N>& arr) noexcept;
    template<class R>
    constexpr explicit(extent != dynamic_extent) span(R&& r);
    constexpr span(const span& other) noexcept = default;
    template<class OtherElementType, size_t OtherExtent>
    constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept;
// see 24.7.3.7
// Constraints: Extent == dynamic_extent || Extent == 0 is true.
// Postconditions: size() == 0 && data() == nullptr.
    ~span() noexcept = default;
    constexpr span& operator=(const span& other) noexcept = default;
// 24.7.3.4, subviews template<size_t Count>
    constexpr span<element_type, Count> first() const;
    template<size_t Count>
    constexpr span<element_type, Count> last() const;
    template<size_t Offset, size_t Count = dynamic_extent>
    constexpr span<element_type, see_below> subspan() const;
    constexpr span<element_type, dynamic_extent> first(size_type count) const;
    constexpr span<element_type, dynamic_extent> last(size_type count) const;
    constexpr span<element_type, dynamic_extent> subspan(
        size_type offset, size_type count = dynamic_extent) const;
// 24.7.3.5, observers
    constexpr size_type size() const noexcept;
    constexpr size_type size_bytes() const noexcept;
    [[nodiscard]] constexpr bool empty() const noexcept;
// 24.7.3.6, element access
    constexpr reference operator[](size_type idx) const;
    constexpr reference front() const;
    constexpr reference back() const;
    constexpr pointer data() const noexcept;
// 24.7.3.7, iterator support
    constexpr iterator begin() const noexcept;
    constexpr iterator end() const noexcept;
    constexpr reverse_iterator rbegin() const noexcept;
    constexpr reverse_iterator rend() const noexcept;
private:
    pointer data_; // exposition only size_type size_; // exposition only
};
template<class It, class EndOrSize>
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
template<class T, size_t N>
span(T (&)[N]) -> span<T, N>;
template<class T, size_t N>
span(array<T, N>&) -> span<T, N>;
template<class T, size_t N>
span(const array<T, N>&) -> span<const T, N>;
template<class R>
span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
}
// span<ElementType, Extent> is a trivially copyable type (6.8.1).
//  ElementType is required to be a complete object type that is not an abstract class type.
// 24.7.3.2 Constructors, copy, and assignment [span.cons]
constexpr span() noexcept;
template<class It>
constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
// Constraints: Let U be remove_reference_t<iter_reference_t<It>>.
// — It satisfies contiguous_iterator.
// — is_convertible_v<U(*)[], element_type(*)[]> is true.
// [Note 1 : The intent is to allow only qualification conversions of the iterator reference type to element_type.
// Preconditions: — [first, first + count) is a valid range.
// — It models contiguous_iterator.
// — If extent is not equal to dynamic_extent, then count is equal to extent.
// Effects: Initializes data_ with to_address(first) and size_ with count. Throws: Nothing.
template<class It, class End>
constexpr explicit(extent != dynamic_extent) span(It first, End last);
// Constraints: Let U be remove_reference_t<iter_reference_t<It>>. — is_convertible_v<U(*)[], element_type(*)[]> is true.
// [Note 2 : The intent is to allow only qualification conversions of the iterator reference type to element_type.
// — It satisfies contiguous_iterator.
// — End satisfies sized_sentinel_for<It>.
// — is_convertible_v<End, size_t> is false.
// Preconditions: — If extent is not equal to dynamic_extent, then last - first is equal to extent. — [first, last) is a valid range.
// — It models contiguous_iterator.
// — End models sized_sentinel_for<It>.
// Effects: Initializes data_ with to_address(first) and size_ with last - first. Throws: When and what last - first throws.
template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;
template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;
// Constraints: Let U be remove_pointer_t<decltype(data(arr))>.
// — extent == dynamic_extent || N == extent is true, and
// — is_convertible_v<U(*)[], element_type(*)[]> is true.
// [Note 3: The intent is to allow only qualification conversions of the array element type to element_type.
// Effects: Constructs a span that is a view over the supplied array.
// [Note 4: type_identity_t affects class template argument deduction.
//  Postconditions: size() == N && data() == data(arr) is true.
template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
// Constraints: Let U be remove_reference_t<ranges::range_reference_t<R>>.
// — R satisfies ranges::contiguous_range and ranges::sized_range.
// — Either R satisfies ranges::borrowed_range or is_const_v<element_type> is true.
// — remove_cvref_t<R> is not a specialization of span.
// — remove_cvref_t<R> is not a specialization of array.
// — is_array_v<remove_cvref_t<R>> is false.
// — is_convertible_v<U(*)[], element_type(*)[]> is true.
// [Note 5: The intent is to allow only qualification conversions of the range reference type to element_type.
// Preconditions:— If extent is not equal to dynamic_extent, then ranges::size(r) is equal to extent. — R models ranges::contiguous_range and ranges::sized_range.
// — If is_const_v<element_type> is false, R models ranges::borrowed_range.
// Effects: Initializes data_ with ranges::data(r) and size_ with ranges::size(r). Throws: What and when ranges::data(r) and ranges::size(r) throw.
constexpr span(const span& other) noexcept = default;
// Postconditions: other.size() == size() && other.data() == data(). template<class OtherElementType, size_t OtherExtent>
constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept;
Constraints:
// — extent == dynamic_extent || OtherExtent == dynamic_extent || extent == OtherExtent is true, and
// — is_convertible_v<OtherElementType(*)[], element_type(*)[]> is true.
// [Note 6: The intent is to allow only qualification conversions of the OtherElementType to element_type.
// Preconditions: If extent is not equal to dynamic_extent, then s.size() is equal to extent. Effects: Constructs a span that is a view over the range [s.data(), s.data() + s.size()). // Postconditions: size() == s.size() && data() == s.data().
// Remarks: The expression inside explicit is equivalent to:
extent != dynamic_extent && OtherExtent == dynamic_extent
constexpr span& operator=(const span& other) noexcept = default;
// Postconditions: size() == other.size() && data() == other.data().
// 24.7.3.3 Deduction guides [span.deduct]
template<class It, class EndOrSize>
span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
// Constraints: It satisfies contiguous_iterator. template<class R>
span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
// Constraints: R satisfies ranges::contiguous_range.
// 24.7.3.4 Subviews [span.sub]
template<size_t Count> constexpr span<element_type, Count> first() const;
// Mandates: Count <= Extent is true.
// Preconditions: Count <= size() is true.
// Effects: Equivalent to: return R{data(), Count}; where R is the return type.
template<size_t Count> constexpr span<element_type, Count> last() const;
// Mandates: Count <= Extent is true.
// Preconditions: Count <= size() is true.
// ffects: Equivalent to: return R{data() + (size() - Count), Count}; where R is the return type.
template<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
// Mandates:
Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset)
// is true.
// Preconditions:
Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset)
// is true.
// Effects: Equivalent to:
return span<ElementType, see_below>(
           data() + Offset, Count != dynamic_extent ? Count : size() - Offset);
// Remarks: The second template argument of the returned span type is:
Count != dynamic_extent ? Count   : (Extent != dynamic_extent ? Extent - Offset    dynamic_extent)
constexpr span<element_type, dynamic_extent> first(size_type count) const;
// Preconditions: count <= size() is true.
// Effects: Equivalent to: return {data(), count};
constexpr span<element_type, dynamic_extent> last(size_type count) const;
// Preconditions: count <= size() is true.
// Effects: Equivalent to: return {data() + (size() - count), count};
constexpr span<element_type, dynamic_extent> subspan(
    size_type offset, size_type count = dynamic_extent) const;
// Preconditions:
offset <= size() && (count == dynamic_extent || count <= size() - offset)
// is true.
// Effects: Equivalent to:
return {data() + offset, count == dynamic_extent ? size() - offset : count};
// 24.7.3.5 Observers [span.obs]
constexpr size_type size() const noexcept;
// Effects: Equivalent to: return size_; constexpr size_type size_bytes() const noexcept;
// Effects: Equivalent to: return size() * sizeof(element_type); [[nodiscard]] constexpr bool empty() const noexcept;
// Effects: Equivalent to: return size() == 0;
// 24.7.3.6 Element access [span.elem]
constexpr reference operator[](size_type idx) const;
// Preconditions: idx < size() is true.
// Effects: Equivalent to: return *(data() + idx);
constexpr reference front() const;
// Preconditions: empty() is false.
// Effects: Equivalent to: return *data();
constexpr reference back() const;
// Preconditions: empty() is false.
// Effects: Equivalent to: return *(data() + (size() - 1));
constexpr pointer data() const noexcept;
// Effects: Equivalent to: return data_;
// 24.7.3.7 Iterator support [span.iterators]
using iterator = implementation-defined;
// The type models contiguous_iterator (25.3.4.14), meets the Cpp17RandomAccessIterator require- ments (25.3.5.7), and meets the requirements for constexpr iterators (25.3.1), whose value type is value_type and whose reference type is reference.
All requirements on container iterators (24.2) apply to span::iterator as well. constexpr iterator begin() const noexcept;
// Returns: An iterator referring to the first element in the span. If empty() is true, then it returns the same value as end().
constexpr iterator end() const noexcept;
// Returns: An iterator which is the past-the-end value. constexpr reverse_iterator rbegin() const noexcept;
// Effects: Equivalent to: return reverse_iterator(end()); constexpr reverse_iterator rend() const noexcept;
// Effects: Equivalent to: return reverse_iterator(begin());
// 24.7.3.8 Views of object representation [span.objectrep]
template<class ElementType, size_t Extent>
span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
as_bytes(span<ElementType, Extent> s) noexcept;
// Effects: Equivalent to: return R{reinterpret_cast<const byte*>(s.data()), s.size_bytes()}; where R is the return type.
template<class ElementType, size_t Extent>
span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
as_writable_bytes(span<ElementType, Extent> s) noexcept;
// Constraints: is_const_v<ElementType> is false.
// Effects: Equivalent to: return R{reinterpret_cast<byte*>(s.data()), s.size_bytes()}; where R is the return type.
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}

編纂・実行結果(compile and go)

bash
$ clang++ p960.cpp -std=03 -o p960l -I. -Wall
In file included from p960.cpp:10:
In file included from ./N4910.h:11:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/atomic:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
 ^
p960.cpp:19:12: error: unknown type name 'constexpr'
    inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
           ^
p960.cpp:19:5: warning: inline variables are a C++17 extension [-Wc++17-extensions]
    inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
    ^
p960.cpp:19:28: error: expected ';' after top level declarator
    inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
                           ^
                           ;
p960.cpp:21:45: error: use of undeclared identifier 'dynamic_extent'; did you mean 'dynamic_cast'?
template<class ElementType, size_t Extent = dynamic_extent>
                                            ^~~~~~~~~~~~~~
                                            dynamic_cast
p960.cpp:21:59: error: expected '<' after 'dynamic_cast'
template<class ElementType, size_t Extent = dynamic_extent>
                                                          ^
                                                          <
p960.cpp:24:14: error: unknown type name 'constexpr'
      inline constexpr bool ranges::enable_view<span<ElementType, Extent>> = true;
             ^
p960.cpp:24:29: error: use of undeclared identifier 'ranges'
      inline constexpr bool ranges::enable_view<span<ElementType, Extent>> = true;
                            ^
p960.cpp:26:17: error: unknown type name 'constexpr'
         inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
                ^
p960.cpp:26:32: error: use of undeclared identifier 'ranges'
         inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
                               ^
p960.cpp:28:21: error: unknown type name 'byte'
         span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
                    ^
p960.cpp:29:26: error: use of undeclared identifier 'ElementType'
           as_bytes(span<ElementType, Extent> s) noexcept;
                         ^
p960.cpp:29:50: error: expected function body after function declarator
           as_bytes(span<ElementType, Extent> s) noexcept;
                                                 ^
p960.cpp:31:15: error: use of undeclared identifier 'byte'
         span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
              ^
p960.cpp:32:58: error: expected ';' at end of declaration
           as_writable_bytes(span<ElementType, Extent> s) noexcept;
                                                         ^
                                                         ;
p960.cpp:32:59: error: C++ requires a type specifier for all declarations
           as_writable_bytes(span<ElementType, Extent> s) noexcept;
                                                          ^
p960.cpp:39:52: error: use of undeclared identifier 'dynamic_extent'; did you mean 'dynamic_cast'?
       template<class ElementType, size_t Extent = dynamic_extent>
                                                   ^~~~~~~~~~~~~~
                                                   dynamic_cast
p960.cpp:39:66: error: expected '<' after 'dynamic_cast'
       template<class ElementType, size_t Extent = dynamic_extent>
                                                                 ^
                                                                 <
p960.cpp:43:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using element_type = ElementType;
                     ^
p960.cpp:44:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using value_type = remove_cv_t<ElementType>;
                   ^
p960.cpp:44:20: error: no template named 'remove_cv_t'
p960.cpp:45:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using size_type = size_t;
                  ^
p960.cpp:46:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using difference_type = ptrdiff_t;
                        ^
p960.cpp:47:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using pointer = element_type*;
                ^
p960.cpp:48:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using const_pointer = const element_type*;
                      ^
p960.cpp:49:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using reference = element_type&;
                  ^
p960.cpp:50:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using const_reference = const element_type&;
                        ^
p960.cpp:51:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using iterator = implementation_defined ;
                 ^
p960.cpp:51:18: error: unknown type name 'implementation_defined'
p960.cpp:52:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using reverse_iterator = std::reverse_iterator<iterator>; static constexpr size_type extent = Extent;
                         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
11 warnings and 20 errors generated.
$ clang++ p960.cpp -std=2b -o p960l -I. -Wall
p960.cpp:28:27: error: use of undeclared identifier 'Extent'; did you mean 'extent'?
         span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
                          ^~~~~~
                          extent
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/type_traits:1372:12: note: 'extent' declared here
    struct extent
           ^
p960.cpp:28:78: error: use of undeclared identifier 'ElementType'
         span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
                                                                             ^
p960.cpp:28:93: error: use of undeclared identifier 'Extent'
         span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
                                                                                            ^
p960.cpp:28:27: error: use of undeclared identifier 'Extent'
         span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
                          ^
p960.cpp:29:26: error: use of undeclared identifier 'ElementType'
           as_bytes(span<ElementType, Extent> s) noexcept;
                         ^
p960.cpp:39:52: error: template parameter redefines default argument
       template<class ElementType, size_t Extent = dynamic_extent>
                                                   ^
p960.cpp:21:45: note: previous default template argument defined here
template<class ElementType, size_t Extent = dynamic_extent>
                                            ^
p960.cpp:51:18: error: unknown type name 'implementation_defined'
using iterator = implementation_defined ;
                 ^
p960.cpp:52:48: error: use of class template 'iterator' requires template arguments
using reverse_iterator = std::reverse_iterator<iterator>; static constexpr size_type extent = Extent;
                                               ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:127:12: note: template is declared here
    struct iterator
           ^
p960.cpp:68:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept;
                   ^
p960.cpp:75:41: error: use of undeclared identifier 'Count'; did you mean 'count'?
           constexpr span<element_type, Count> first() const;
                                        ^~~~~
                                        count
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_algo.h:4078:5: note: 'count' declared here
    count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
    ^
p960.cpp:75:41: error: value of type '<overloaded function type>' is not implicitly convertible to 'std::size_t' (aka 'unsigned long')
           constexpr span<element_type, Count> first() const;
                                        ^~~~~
p960.cpp:79:30: error: use of undeclared identifier 'see_below'
constexpr span<element_type, see_below> subspan() const;
                             ^
p960.cpp:92:11: error: use of class template 'iterator' requires template arguments; argument deduction not allowed in function return type
constexpr iterator begin() const noexcept; constexpr iterator end() const noexcept;
          ^~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:127:12: note: template is declared here
    struct iterator
           ^
p960.cpp:92:54: error: use of class template 'iterator' requires template arguments; argument deduction not allowed in function return type
constexpr iterator begin() const noexcept; constexpr iterator end() const noexcept;
                                                     ^~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:127:12: note: template is declared here
    struct iterator
           ^
p960.cpp:93:11: error: use of class template 'reverse_iterator' requires template arguments; argument deduction not allowed in function return type
constexpr reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() const noexcept;
          ^~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:125:11: note: template is declared here
    class reverse_iterator
          ^
p960.cpp:93:63: error: use of class template 'reverse_iterator' requires template arguments; argument deduction not allowed in function return type
constexpr reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() const noexcept;
                                                              ^~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:125:11: note: template is declared here
    class reverse_iterator
          ^
p960.cpp:111:14: error: deduction guide must be declared in the same scope as template 'std::span'
   constexpr span() noexcept;
             ^
p960.cpp:40:14: note: template is declared here
       class span {
             ^
p960.cpp:111:14: error: deduction guide cannot be declared 'constexpr'
   constexpr span() noexcept;
   ~~~~~~~~~ ^
p960.cpp:111:14: error: deduction guide declaration without trailing return type
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p960.cpp -std=03 -o p960g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p960.cpp:10:
/usr/local/include/c++/12.1.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   32 | #error This file requires compiler and library support \
      |  ^~~~~
p960.cpp:19:12: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   19 |     inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
      |            ^~~~~~~~~
p960.cpp:29:50: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                                                  ^~~~~~~~
p960.cpp:19:12: error: 'constexpr' does not name a type
   19 |     inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
      |            ^~~~~~~~~
p960.cpp:19:12: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:21:45: error: 'dynamic_extent' was not declared in this scope
   21 | template<class ElementType, size_t Extent = dynamic_extent>
      |                                             ^~~~~~~~~~~~~~
p960.cpp:24:14: error: 'constexpr' does not name a type
   24 |       inline constexpr bool ranges::enable_view<span<ElementType, Extent>> = true;
      |              ^~~~~~~~~
p960.cpp:24:14: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:26:17: error: 'constexpr' does not name a type
   26 |          inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
      |                 ^~~~~~~~~
p960.cpp:26:17: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:28:21: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
   28 |          span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                     ^~~~
p960.cpp:28:99: error: template argument 1 is invalid
   28 |          span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                                                   ^
p960.cpp:28:99: error: template argument 2 is invalid
p960.cpp:29:26: error: 'ElementType' was not declared in this scope
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                          ^~~~~~~~~~~
p960.cpp:29:39: error: 'Extent' was not declared in this scope
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                                       ^~~~~~
p960.cpp:29:45: error: template argument 1 is invalid
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                                             ^
p960.cpp:29:45: error: template argument 2 is invalid
p960.cpp:29:50: error: expected initializer before 'noexcept'
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                                                  ^~~~~~~~
p960.cpp:31:15: error: 'byte' was not declared in this scope
   31 |          span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |               ^~~~
p960.cpp:31:15: note: 'std::byte' is only available from C++17 onwards
p960.cpp:31:31: error: 'dynamic_extent' was not declared in this scope
   31 |          span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                               ^~~~~~~~~~~~~~
p960.cpp:31:48: error: 'dynamic_extent' was not declared in this scope
   31 |          span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                ^~~~~~~~~~~~~~
p960.cpp:31:93: error: template argument 1 is invalid
   31 |          span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                                             ^
p960.cpp:31:93: error: template argument 2 is invalid
p960.cpp:32:59: error: expected initializer before 'noexcept'
   32 |            as_writable_bytes(span<ElementType, Extent> s) noexcept;
      |                                                           ^~~~~~~~
p960.cpp:39:52: error: 'dynamic_extent' was not declared in this scope
   39 |        template<class ElementType, size_t Extent = dynamic_extent>
      |                                                    ^~~~~~~~~~~~~~
p960.cpp:39:52: error: redefinition of default argument for 'long unsigned int Extent'
p960.cpp:21:45: note: original definition appeared here
   21 | template<class ElementType, size_t Extent = dynamic_extent>
      |                                             ^~~~~~~~~~~~~~
p960.cpp:98:38: error: 'remove_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                      ^~~~~~~~~~~~~~~~~~
p960.cpp:98:57: error: 'iter_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                         ^~~~~~~~~~~~~~~~
p960.cpp:98:78: error: template argument 1 is invalid
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                              ^
p960.cpp:98:78: error: template argument 2 is invalid
p960.cpp:98:38: error: 'remove_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                      ^~~~~~~~~~~~~~~~~~
p960.cpp:98:57: error: 'iter_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                         ^~~~~~~~~~~~~~~~
p960.cpp:98:78: error: template argument 1 is invalid
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                              ^
p960.cpp:98:78: error: template argument 2 is invalid
p960.cpp:98:38: error: 'remove_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                      ^~~~~~~~~~~~~~~~~~
p960.cpp:98:57: error: 'iter_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                         ^~~~~~~~~~~~~~~~
p960.cpp:98:78: error: template argument 1 is invalid
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                              ^
p960.cpp:98:78: error: template argument 2 is invalid
p960.cpp:98:38: error: 'remove_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                      ^~~~~~~~~~~~~~~~~~
p960.cpp:98:57: error: 'iter_reference_t' was not declared in this scope
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                         ^~~~~~~~~~~~~~~~
p960.cpp:98:78: error: template argument 1 is invalid
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                              ^
p960.cpp:98:78: error: template argument 2 is invalid
p960.cpp:98:33: error: invalid use of template-name 'std::span' without an argument list
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                 ^~~~
p960.cpp:98:33: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++1'
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:98:37: error: expected constructor, destructor, or type conversion before '<' token
   98 |          span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                     ^
p960.cpp:100:38: error: expected constructor, destructor, or type conversion before ';' token
  100 |          span(T (&)[N]) -> span<T, N>;
      |                                      ^
p960.cpp:102:14: error: expected constructor, destructor, or type conversion before '(' token
  102 |          span(array<T, N>&) -> span<T, N>;
      |              ^
p960.cpp:104:21: error: 'array' does not name a type
  104 |          span(const array<T, N>&) -> span<const T, N>;
      |                     ^~~~~
p960.cpp:104:26: error: expected ',' or '...' before '<' token
  104 |          span(const array<T, N>&) -> span<const T, N>;
      |                          ^
p960.cpp:104:54: error: expected constructor, destructor, or type conversion before ';' token
  104 |          span(const array<T, N>&) -> span<const T, N>;
      |                                                      ^
p960.cpp:106:16: error: expected ',' or '...' before '&&' token
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                ^~
p960.cpp:106:28: error: 'remove_reference_t' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                            ^~~~~~~~~~~~~~~~~~
p960.cpp:106:47: error: 'ranges' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                               ^~~~~~
p960.cpp:106:76: error: template argument 1 is invalid
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                                                            ^
p960.cpp:106:76: error: template argument 2 is invalid
p960.cpp:106:28: error: 'remove_reference_t' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                            ^~~~~~~~~~~~~~~~~~
p960.cpp:106:47: error: 'ranges' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                               ^~~~~~
p960.cpp:106:76: error: template argument 1 is invalid
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                                                            ^
p960.cpp:106:76: error: template argument 2 is invalid
p960.cpp:106:28: error: 'remove_reference_t' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                            ^~~~~~~~~~~~~~~~~~
p960.cpp:106:47: error: 'ranges' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                               ^~~~~~
p960.cpp:106:76: error: template argument 1 is invalid
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                                                            ^
p960.cpp:106:76: error: template argument 2 is invalid
p960.cpp:106:28: error: 'remove_reference_t' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                            ^~~~~~~~~~~~~~~~~~
p960.cpp:106:47: error: 'ranges' was not declared in this scope
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                               ^~~~~~
p960.cpp:106:76: error: template argument 1 is invalid
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                                                                            ^
p960.cpp:106:76: error: template argument 2 is invalid
p960.cpp:106:23: error: invalid use of template-name 'std::span' without an argument list
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                       ^~~~
p960.cpp:106:23: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:106:27: error: expected constructor, destructor, or type conversion before '<' token
  106 |          span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |                           ^
p960.cpp:111:4: error: 'constexpr' does not name a type
  111 |    constexpr span() noexcept;
      |    ^~~~~~~~~
p960.cpp:111:4: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:113:3: error: 'constexpr' does not name a type
  113 |   constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
      |   ^~~~~~~~~
p960.cpp:113:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:123:3: error: 'constexpr' does not name a type
  123 |   constexpr explicit(extent != dynamic_extent) span(It first, End last);
      |   ^~~~~~~~~
p960.cpp:123:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:133:20: error: 'constexpr' does not name a type
  133 | template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
      |                    ^~~~~~~~~
p960.cpp:133:20: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:134:29: error: 'constexpr' does not name a type
  134 | template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;
      |                             ^~~~~~~~~
p960.cpp:134:29: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:135:29: error: 'constexpr' does not name a type
  135 | template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;
      |                             ^~~~~~~~~
p960.cpp:135:29: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:143:19: error: 'constexpr' does not name a type
  143 | template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
      |                   ^~~~~~~~~
p960.cpp:143:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:155:1: error: 'constexpr' does not name a type
  155 | constexpr span(const span& other) noexcept = default;
      | ^~~~~~~~~
p960.cpp:155:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:157:1: error: 'constexpr' does not name a type
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      | ^~~~~~~~~
p960.cpp:157:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:157:103: error: found ':' in nested-name-specifier, expected '::'
  157 | texpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                                                                                   ^
      |                                                                                                   :
p960.cpp:157:92: error: 'Constraints' does not name a type
  157 | stexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                                                                         ^~~~~~~~~~~

p960.cpp:168:31: error: 'remove_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                               ^~~~~~~~~~~~~~~~~~
p960.cpp:168:50: error: 'iter_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                  ^~~~~~~~~~~~~~~~
p960.cpp:168:71: error: template argument 1 is invalid
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                       ^
p960.cpp:168:71: error: template argument 2 is invalid
p960.cpp:168:31: error: 'remove_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                               ^~~~~~~~~~~~~~~~~~
p960.cpp:168:50: error: 'iter_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                  ^~~~~~~~~~~~~~~~
p960.cpp:168:71: error: template argument 1 is invalid
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                       ^
p960.cpp:168:71: error: template argument 2 is invalid
p960.cpp:168:31: error: 'remove_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                               ^~~~~~~~~~~~~~~~~~
p960.cpp:168:50: error: 'iter_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                  ^~~~~~~~~~~~~~~~
p960.cpp:168:71: error: template argument 1 is invalid
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                       ^
p960.cpp:168:71: error: template argument 2 is invalid
p960.cpp:168:31: error: 'remove_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                               ^~~~~~~~~~~~~~~~~~
p960.cpp:168:50: error: 'iter_reference_t' was not declared in this scope
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                  ^~~~~~~~~~~~~~~~
p960.cpp:168:71: error: template argument 1 is invalid
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                                                                       ^
p960.cpp:168:71: error: template argument 2 is invalid
p960.cpp:168:26: error: invalid use of template-name 'std::span' without an argument list
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                          ^~~~
p960.cpp:168:26: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:168:30: error: expected constructor, destructor, or type conversion before '<' token
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |                              ^
p960.cpp:170:7: error: expected constructor, destructor, or type conversion before '(' token
  170 |   span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |       ^
p960.cpp:173:24: error: 'constexpr' does not name a type
  173 | template<size_t Count> constexpr span<element_type, Count> first() const;
      |                        ^~~~~~~~~
p960.cpp:173:24: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:177:24: error: 'constexpr' does not name a type
  177 | template<size_t Count> constexpr span<element_type, Count> last() const;
      |                        ^~~~~~~~~
p960.cpp:177:24: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:181:40: error: 'dynamic_extent' was not declared in this scope
  181 | template<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                        ^~~~~~~~~~~~~~
p960.cpp:181:56: error: 'constexpr' does not name a type
  181 | template<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                                        ^~~~~~~~~
p960.cpp:181:56: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:183:3: error: 'Offset' does not name a type
  183 |   Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset)
      |   ^~~~~~
p960.cpp:192:3: error: 'Count' does not name a type
  192 |   Count != dynamic_extent ? Count   : (Extent != dynamic_extent ? Extent - Offset    dynamic_extent)
      |   ^~~~~
p960.cpp:196:1: error: 'constexpr' does not name a type
  196 | constexpr span<element_type, dynamic_extent> last(size_type count) const;
      | ^~~~~~~~~
p960.cpp:196:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:199:1: error: 'constexpr' does not name a type
  199 | constexpr span<element_type, dynamic_extent> subspan(
      | ^~~~~~~~~
p960.cpp:199:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:202:1: error: 'offset' does not name a type; did you mean 'off_t'?
  202 | offset <= size() && (count == dynamic_extent || count <= size() - offset)
      | ^~~~~~
      | off_t
p960.cpp:207:1: error: 'constexpr' does not name a type
  207 | constexpr size_type size() const noexcept;
      | ^~~~~~~~~
p960.cpp:207:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:212:1: error: 'constexpr' does not name a type
  212 | constexpr reference operator[](size_type idx) const;
      | ^~~~~~~~~
p960.cpp:212:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:215:1: error: 'constexpr' does not name a type
  215 | constexpr reference front() const;
      | ^~~~~~~~~
p960.cpp:215:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:218:1: error: 'constexpr' does not name a type
  218 | constexpr reference back() const;
      | ^~~~~~~~~
p960.cpp:218:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:221:1: error: 'constexpr' does not name a type
  221 | constexpr pointer data() const noexcept;
      | ^~~~~~~~~
p960.cpp:221:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:224:7: error: expected nested-name-specifier before 'iterator'
  224 | using iterator = implementation-defined;
      |       ^~~~~~~~
p960.cpp:226:1: error: 'All' does not name a type
  226 | All requirements on container iterators (24.2) apply to span::iterator as well. constexpr iterator begin() const noexcept;
      | ^~~
p960.cpp:228:1: error: 'constexpr' does not name a type
  228 | constexpr iterator end() const noexcept;
      | ^~~~~~~~~
p960.cpp:228:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p960.cpp:234:14: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
  234 |   span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |              ^~~~
p960.cpp:234:92: error: template argument 1 is invalid
  234 |   span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                                            ^
p960.cpp:234:92: error: template argument 2 is invalid
p960.cpp:235:39: error: expected initializer before 'noexcept'
  235 | as_bytes(span<ElementType, Extent> s) noexcept;
      |                                       ^~~~~~~~
p960.cpp:238:8: error: 'byte' was not declared in this scope
  238 |   span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |        ^~~~
p960.cpp:238:8: note: 'std::byte' is only available from C++17 onwards
p960.cpp:238:24: error: 'dynamic_extent' was not declared in this scope
  238 |   span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                        ^~~~~~~~~~~~~~
p960.cpp:238:41: error: 'dynamic_extent' was not declared in this scope
  238 |   span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                         ^~~~~~~~~~~~~~
p960.cpp:238:86: error: template argument 1 is invalid
  238 |   span<byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                                      ^
p960.cpp:238:86: error: template argument 2 is invalid
p960.cpp:239:48: error: expected initializer before 'noexcept'
  239 | as_writable_bytes(span<ElementType, Extent> s) noexcept;
      |                                                ^~~~~~~~

$ g++ p960.cpp -std=2b -o p960g -I. -Wall
p960.cpp:28:27: error: 'Extent' was not declared in this scope; did you mean 'extent'?
   28 |          span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                           ^~~~~~
      |                           extent
p960.cpp:28:78: error: 'ElementType' was not declared in this scope
   28 |          span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                              ^~~~~~~~~~~
p960.cpp:28:93: error: 'Extent' was not declared in this scope; did you mean 'extent'?
   28 |          span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                                             ^~~~~~
      |                                                                                             extent
p960.cpp:28:99: error: template argument 2 is invalid
   28 |          span<const byte, Extent == dynamic_extent ? dynamic_extent : sizeof(ElementType) * Extent>
      |                                                                                                   ^
p960.cpp:29:26: error: 'ElementType' was not declared in this scope
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                          ^~~~~~~~~~~
p960.cpp:29:39: error: 'Extent' was not declared in this scope; did you mean 'extent'?
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                                       ^~~~~~
      |                                       extent
p960.cpp:29:45: error: template argument 1 is invalid
   29 |            as_bytes(span<ElementType, Extent> s) noexcept;
      |                                             ^
p960.cpp:29:45: error: template argument 2 is invalid
p960.cpp:39:52: error: redefinition of default argument for 'long unsigned int Extent'
   39 |        template<class ElementType, size_t Extent = dynamic_extent>
      |                                                    ^~~~~~~~~~~~~~
p960.cpp:21:45: note: original definition appeared here
   21 | template<class ElementType, size_t Extent = dynamic_extent>
      |                                             ^~~~~~~~~~~~~~
p960.cpp:111:4: error: 'decl-specifier' in declaration of deduction guide
  111 |    constexpr span() noexcept;
      |    ^~~~~~~~~
p960.cpp:111:14: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  111 |    constexpr span() noexcept;
      |              ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:113:29: error: missing template arguments before '!=' token
  113 |   constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
      |                             ^~
p960.cpp:113:63: error: 'size_type' has not been declared
  113 |   constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
      |                                                               ^~~~~~~~~
p960.cpp:113:3: error: 'decl-specifier' in declaration of deduction guide
  113 |   constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
      |   ^~~~~~~~~
p960.cpp:113:48: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  113 |   constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
      |                                                ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:123:29: error: missing template arguments before '!=' token
  123 |   constexpr explicit(extent != dynamic_extent) span(It first, End last);
      |                             ^~
p960.cpp:123:3: error: 'decl-specifier' in declaration of deduction guide
  123 |   constexpr explicit(extent != dynamic_extent) span(It first, End last);
      |   ^~~~~~~~~
p960.cpp:123:48: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  123 |   constexpr explicit(extent != dynamic_extent) span(It first, End last);
      |                                                ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:133:51: error: 'element_type' was not declared in this scope
  133 | template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
      |                                                   ^~~~~~~~~~~~
p960.cpp:133:63: error: template argument 1 is invalid
  133 | template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
      |                                                               ^
p960.cpp:133:20: error: 'decl-specifier' in declaration of deduction guide
  133 | template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
      |                    ^~~~~~~~~
p960.cpp:133:30: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  133 | template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
      |                              ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:134:29: error: 'decl-specifier' in declaration of deduction guide
  134 | template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;
      |                             ^~~~~~~~~
p960.cpp:134:39: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  134 | template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;
      |                                       ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:135:29: error: 'decl-specifier' in declaration of deduction guide
  135 | template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;
      |                             ^~~~~~~~~
p960.cpp:135:39: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  135 | template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;
      |                                       ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:143:45: error: missing template arguments before '!=' token
  143 | template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
      |                                             ^~
p960.cpp:143:19: error: 'decl-specifier' in declaration of deduction guide
  143 | template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
      |                   ^~~~~~~~~
p960.cpp:143:64: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  143 | template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
      |                                                                ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:155:16: error: template placeholder type 'const span<...auto...>' must be followed by a simple declarator-id
  155 | constexpr span(const span& other) noexcept = default;
      |                ^~~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:155:1: error: 'decl-specifier' in declaration of deduction guide
  155 | constexpr span(const span& other) noexcept = default;
      | ^~~~~~~~~
p960.cpp:155:11: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  155 | constexpr span(const span& other) noexcept = default;
      |           ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:157:20: error: 'see_below' was not declared in this scope
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                    ^~~~~~~~~
p960.cpp:157:47: error: 'OtherElementType' was not declared in this scope
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                               ^~~~~~~~~~~~~~~~
p960.cpp:157:65: error: 'OtherExtent' was not declared in this scope
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                                                 ^~~~~~~~~~~
p960.cpp:157:76: error: template argument 1 is invalid
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                                                            ^
p960.cpp:157:76: error: template argument 2 is invalid
p960.cpp:157:1: error: 'decl-specifier' in declaration of deduction guide
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      | ^~~~~~~~~
p960.cpp:157:31: error: deduction guide for 'std::span<ElementType, Extent>' must have trailing return type
  157 | constexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                               ^~~~
p960.cpp:22:7: note: 'template<class ElementType, long unsigned int Extent> class std::span' declared here
   22 | class span;
      |       ^~~~
p960.cpp:157:103: error: found ':' in nested-name-specifier, expected '::'
  157 | texpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                                                                                   ^
      |                                                                                                   :
p960.cpp:157:92: error: 'Constraints' does not name a type
  157 | stexpr explicit(see_below) span(const span<OtherElementType, OtherExtent>& s) noexcept; Constraints:
      |                                                                                         ^~~~~~~~~~~

p960.cpp:168:3: error: deduction guide 'span(It, EndOrSize)-> std::span<typename std::remove_reference<std::iter_reference_t<_Tp> >::type>' must be declared in the same scope as 'std::span<ElementType, Extent>'
  168 |   span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>>;
      |   ^~~~
p960.cpp:22:7: note:   declared here
   22 | class span;
      |       ^~~~
p960.cpp:170:9: error: expected ')' before '&&' token
  170 |   span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>;
      |       ~ ^~
      |         )
p960.cpp:173:39: error: 'element_type' was not declared in this scope
  173 | template<size_t Count> constexpr span<element_type, Count> first() const;
      |                                       ^~~~~~~~~~~~
p960.cpp:173:58: error: template argument 1 is invalid
  173 | template<size_t Count> constexpr span<element_type, Count> first() const;
      |                                                          ^
p960.cpp:173:68: error: non-member function 'constexpr int first()' cannot have cv-qualifier
  173 | template<size_t Count> constexpr span<element_type, Count> first() const;
      |                                                                    ^~~~~
p960.cpp:177:39: error: 'element_type' was not declared in this scope
  177 | template<size_t Count> constexpr span<element_type, Count> last() const;
      |                                       ^~~~~~~~~~~~
p960.cpp:177:58: error: template argument 1 is invalid
  177 | template<size_t Count> constexpr span<element_type, Count> last() const;
      |                                                          ^
p960.cpp:177:67: error: non-member function 'constexpr int last()' cannot have cv-qualifier
  177 | template<size_t Count> constexpr span<element_type, Count> last() const;
      |                                                                   ^~~~~
p960.cpp:181:71: error: 'element_type' was not declared in this scope
  181 | template<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                                                       ^~~~~~~~~~~~
p960.cpp:181:85: error: 'see_below' was not declared in this scope
  181 | template<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                                                                     ^~~~~~~~~
p960.cpp:181:94: error: template argument 1 is invalid
  181 | ate<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                                                                         ^

p960.cpp:181:94: error: template argument 2 is invalid
p960.cpp:181:106: error: non-member function 'constexpr int subspan()' cannot have cv-qualifier
  181 | e_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                                                                              ^~~~~

p960.cpp:183:3: error: 'Offset' does not name a type
  183 |   Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset)
      |   ^~~~~~
p960.cpp:192:3: error: 'Count' does not name a type
  192 |   Count != dynamic_extent ? Count   : (Extent != dynamic_extent ? Extent - Offset    dynamic_extent)
      |   ^~~~~
p960.cpp:196:16: error: 'element_type' was not declared in this scope
  196 | constexpr span<element_type, dynamic_extent> last(size_type count) const;
      |                ^~~~~~~~~~~~
p960.cpp:196:44: error: template argument 1 is invalid
  196 | constexpr span<element_type, dynamic_extent> last(size_type count) const;
      |                                            ^
p960.cpp:196:51: error: 'constexpr const int last' redeclared as different kind of entity
  196 | constexpr span<element_type, dynamic_extent> last(size_type count) const;
      |                                                   ^~~~~~~~~
p960.cpp:177:60: note: previous declaration 'template<long unsigned int Count> constexpr int last()'
  177 | template<size_t Count> constexpr span<element_type, Count> last() const;
      |                                                            ^~~~
p960.cpp:196:51: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
  196 | constexpr span<element_type, dynamic_extent> last(size_type count) const;
      |                                                   ^~~~~~~~~
      |                                                   size_t
p960.cpp:199:16: error: 'element_type' was not declared in this scope
  199 | constexpr span<element_type, dynamic_extent> subspan(
      |                ^~~~~~~~~~~~
p960.cpp:199:44: error: template argument 1 is invalid
  199 | constexpr span<element_type, dynamic_extent> subspan(
      |                                            ^
p960.cpp:200:3: error: 'constexpr const int subspan' redeclared as different kind of entity
  200 |   size_type offset, size_type count = dynamic_extent) const;
      |   ^~~~~~~~~
p960.cpp:181:96: note: previous declaration 'template<long unsigned int Offset, long unsigned int Count> constexpr int subspan()'
  181 | e<size_t Offset, size_t Count = dynamic_extent> constexpr span<element_type, see_below> subspan() const;
      |                                                                                         ^~~~~~~

p960.cpp:200:3: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
  200 |   size_type offset, size_type count = dynamic_extent) const;
      |   ^~~~~~~~~
      |   size_t
p960.cpp:200:21: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
  200 |   size_type offset, size_type count = dynamic_extent) const;
      |                     ^~~~~~~~~
      |                     size_t
p960.cpp:202:1: error: 'offset' does not name a type; did you mean 'off_t'?
  202 | offset <= size() && (count == dynamic_extent || count <= size() - offset)
      | ^~~~~~
      | off_t
p960.cpp:207:11: error: 'size_type' does not name a type; did you mean 'size_t'?
  207 | constexpr size_type size() const noexcept;
      |           ^~~~~~~~~
      |           size_t
p960.cpp:212:11: error: 'reference' does not name a type
  212 | constexpr reference operator[](size_type idx) const;
      |           ^~~~~~~~~
p960.cpp:215:11: error: 'reference' does not name a type
  215 | constexpr reference front() const;
      |           ^~~~~~~~~
p960.cpp:218:11: error: 'reference' does not name a type
  218 | constexpr reference back() const;
      |           ^~~~~~~~~
p960.cpp:221:11: error: 'pointer' does not name a type
  221 | constexpr pointer data() const noexcept;
      |           ^~~~~~~
p960.cpp:224:18: error: 'implementation' does not name a type
  224 | using iterator = implementation-defined;
      |                  ^~~~~~~~~~~~~~
p960.cpp:226:1: error: 'All' does not name a type
  226 | All requirements on container iterators (24.2) apply to span::iterator as well. constexpr iterator begin() const noexcept;
      | ^~~
p960.cpp:228:11: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations]
  228 | constexpr iterator end() const noexcept;
      |           ^~~~~~~~
In file included from /usr/local/include/c++/12.1.0/bits/stl_construct.h:61,
                 from /usr/local/include/c++/12.1.0/bits/char_traits.h:46,
                 from /usr/local/include/c++/12.1.0/ios:40,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from N4910.h:2,
                 from p960.cpp:10:
/usr/local/include/c++/12.1.0/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
p960.cpp:228:11: error: deduced class type 'iterator' in function return type
  228 | constexpr iterator end() const noexcept;
      |           ^~~~~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator_base_types.h:127:34: note: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~

検討事項(agenda)

コンパイルエラーを取るか、コンパイルエラーの理由を解説する。

参考資料(reference)

関連する自己参照以外は、こちらの先頭に移転。

C言語(C++)に対する誤解、曲解、無理解、爽快。

#include "N4910.h"

C++N4910資料の改善点

dockerにclang

docker gnu(gcc/g++) and llvm(clang/clang++)

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)

C++N4910:2022 tag follower 300人超えました。ありがとうございます。

astyle 使ってみた

DoCAP(ドゥーキャップ)って何ですか?

小川メソッド 覚え(書きかけ)

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>

文書履歴(document history)

ver. 0.01 初稿  20220808

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?