はじめに(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.
23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp
算譜(source code)
// 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 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.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;
// 23.3.2 Header <string_view> synopsis // 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 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.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;
// 23.3.2 Header <string_view> synopsis [string.view.synop]
#include <compare> // see 17.11.1
namespace std {
// 23.3.3, class template basic_string_view
template<class charT, class traits = char_traits<charT>> class basic_string_view;
template<class charT, class traits>
inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
template<class charT, class traits>
inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;
// 23.3.5, non-member comparison functions template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr see below operator<=>(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
// see 23.3.5, sufficient additional overloads of comparison functions
// 23.3.6, inserters and extractors template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os,
basic_string_view<charT, traits> str);
// basic_string_view typedef-names
using string_view = basic_string_view<char>;
using u8string_view = basic_string_view<char8_t>;
using u16string_view = basic_string_view<char16_t>;
using u32string_view = basic_string_view<char32_t>;
using wstring_view = basic_string_view<wchar_t>;
// 23.3.7, hash support
template<class T> struct hash;
template<> struct hash<string_view>;
template<> struct hash<u8string_view>;
template<> struct hash<u16string_view>;
template<> struct hash<u32string_view>;
template<> struct hash<wstring_view>;
inline namespace literals {
inline namespace string_view_literals {
// 23.3.8, suffix for basic_string_view literals
constexpr string_view operator""sv(const char* str, size_t len) noexcept;
constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept;
constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
}
}
}
// The function templates defined in 22.2.2 and 25.7 are available when <string_view> is included.
// 23.3.3 Class template basic_string_view [string.view.template]
// 23.3.3.1 General [string.view.template.general]
namespace std {
template<class charT, class traits = char_traits<charT>>
class basic_string_view {
public:
// types
using traits_type = traits;
using value_type = charT;
using pointer = value_type*;
using const_pointer = const value_type*;
using reference = value_type&;
using const_reference = const value_type&;
using const_iterator= implementation-defined ; // see 23.3.3.3
using iterator = const_iterator;
using const_reverse_iterator = reverse_iterator<const_iterator>;
using reverse_iterator = const_reverse_iterator;
using size_type = size_t;
using difference_type = ptrdiff_t;
static constexpr size_type npos = size_type(-1);
// 23.3.3.2, construction and assignment
constexpr basic_string_view() noexcept;
constexpr basic_string_view(const basic_string_view&) noexcept = default;
constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
constexpr basic_string_view(const charT* str);
basic_string_view(nullptr_t) = delete;
constexpr basic_string_view(const charT* str, size_type len);
template<class It, class End>
constexpr basic_string_view(It begin, End end);
template<class R>
constexpr basic_string_view(R&& r);
// 23.3.3.3, iterator support
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// 23.3.3.4, capacity
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
constexpr size_type max_size() const noexcept;
[[nodiscard]] constexpr bool empty() const noexcept;
// 23.3.3.5, element access
constexpr const_reference operator[](size_type pos) const;
constexpr const_reference at(size_type pos) const;
constexpr const_reference front() const;
constexpr const_reference back() const;
constexpr const_pointer data() const noexcept;
// 23.3.3.6, modifiers
constexpr void remove_prefix(size_type n);
constexpr void remove_suffix(size_type n);
constexpr void swap(basic_string_view& s) noexcept;
// 23.3.3.7, string operations
constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
constexpr int compare(basic_string_view s) const noexcept;
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
constexpr int compare(size_type pos1, size_type n1, basic_string_view s,
size_type pos2, size_type n2) const;
constexpr int compare(const charT* s) const;
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
constexpr bool starts_with(basic_string_view x) const noexcept;
constexpr bool starts_with(charT x) const noexcept;
constexpr bool starts_with(const charT* x) const;
constexpr bool ends_with(basic_string_view x) const noexcept;
constexpr bool ends_with(charT x) const noexcept;
constexpr bool ends_with(const charT* x) const;
constexpr bool contains(basic_string_view x) const noexcept;
constexpr bool contains(charT x) const noexcept;
constexpr bool contains(const charT* x) const;
// 23.3.3.8, searching
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
constexpr size_type find(const charT* s, size_type pos = 0) const;
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(const charT* s, size_type pos,
size_type n) const;
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
constexpr size_type find_last_not_of(basic_string_view s,
size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(const charT* s, size_type pos,
size_type n) const;
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
private:
const_pointer data_;
size_type size_;
};
// 23.3.4, deduction guides template<class It, class End>
// exposition only // exposition only
basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
template<class R>
basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
}
// In every specialization basic_string_view<charT, traits>, the type traits shall meet the character traits requirements (23.2).
// [Note 1: The program is ill-formed if traits::char_type is not the same type as charT.
// For a basic_string_view str, any operation that invalidates a pointer in the range
[str.data(),str.data() + str.size())
// invalidates pointers, iterators, and references returned from str’s member functions.
// 3 The complexity of basic_string_view member functions is O(1) unless otherwise specified.
// basic_string_view<charT, traits> is a trivially copyable type (6.8.1).
// 23.3.3.2 Construction and assignment [string.view.cons]
constexpr basic_string_view() noexcept;
// Postconditions: size_ == 0 and data_ == nullptr.
constexpr basic_string_view(const charT* str);
// Preconditions: [str, str + traits::length(str)) is a valid range.
// Effects: Constructs a basic_string_view, initializing data_ with str and initializing size_ with traits::length(str).
// Complexity: O(traits::length(str)).
constexpr basic_string_view(const charT* str, size_type len);
// Preconditions: [str, str + len) is a valid range.
// Effects: Constructs a basic_string_view, initializing data_ with str and initializing size_ with len.
template<class It, class End>
constexpr basic_string_view(It begin, End end);
// Constraints: — It satisfies contiguous_iterator.
// — End satisfies sized_sentinel_for<It>.
// — is_same_v<iter_value_t<It>, charT> is true. — is_convertible_v<End, size_type> is false.
// Preconditions: — [begin, end) is a valid range.
// — It models contiguous_iterator.
// — End models sized_sentinel_for<It>.
// Effects: Initializes data_ with to_address(begin) and initializes size_ with end - begin. Throws: When and what end - begin throws.
template<class R>
constexpr basic_string_view(R&& r);
// Let d be an lvalue of type remove_cvref_t<R>. Constraints:
// — remove_cvref_t<R> is not the same type as basic_string_view, — R models ranges::contiguous_range and ranges::sized_range, — is_same_v<ranges::range_value_t<R>, charT> is true,
// — is_convertible_v<R, const charT*> is false,
// — d.operator ::std::basic_string_view<charT, traits>() is not a valid expression, and
// — if the qualified-id remove_reference_t<R>::traits_type is valid and denotes a type, is_same_- v<remove_reference_t<R>::traits_type, traits> is true.
// Effects: Initializes data_ with ranges::data(r) and size_ with ranges::size(r). Throws: Any exception thrown by ranges::data(r) and ranges::size(r).
// 23.3.3.3 Iterator support [string.view.iterators]
using const_iterator = implementation-defined;
// A type that meets the requirements of a constant Cpp17RandomAccessIterator (25.3.5.7), models contiguous_iterator (25.3.4.14), and meets the constexpr iterator requirements (25.3.1), whose value_type is the template parameter charT.
// All requirements on container iterators (24.2) apply to basic_string_view::const_iterator as well. constexpr const_iterator begin() const noexcept;
constexpr const_iterator cbegin() const noexcept;
// Returns: An iterator such that
// — if !empty(), addressof(*begin()) == data_,
// — otherwise, an unspecified value such that [begin(), end()) is a valid range.
constexpr const_iterator end() const noexcept;
constexpr const_iterator cend() const noexcept;
// Returns: begin() + size().
constexpr const_reverse_iterator rbegin() const noexcept;
constexpr const_reverse_iterator crbegin() const noexcept;
// Returns: const_reverse_iterator(end()).
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
// Returns: const_reverse_iterator(begin()).
// 23.3.3.4 Capacity [string.view.capacity]
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
// Returns: size_.
constexpr size_type max_size() const noexcept;
// Returns: The largest possible number of char-like objects that can be referred to by a basic_string_- view.
[[nodiscard]] constexpr bool empty() const noexcept;
// Returns: size_ == 0.
// 23.3.3.5 Element access [string.view.access]
constexpr const_reference operator[](size_type pos) const;
// Preconditions: pos < size().
// Returns: data_[pos].
// Throws: Nothing.
// [Note 1: Unlike basic_string::operator[], basic_string_view::operator[](size()) has undefined behav- ior instead of returning charT(). —end note]
constexpr const_reference at(size_type pos) const;
// Returns: data_[pos].
// Throws: out_of_range if pos >= size().
constexpr const_reference front() const;
// Preconditions: !empty(). Returns: data_[0]. Throws: Nothing.
constexpr const_reference back() const;
// Preconditions: !empty(). Returns: data_[size() - 1]. Throws: Nothing.
constexpr const_pointer data() const noexcept;
// Returns: data_.
// [Note 2: Unlike basic_string::data() and string-literals, data() can return a pointer to a buffer that is not null-terminated. Therefore it is typically a mistake to pass data() to a function that takes just a const charT* and expects a null-terminated string.
// 23.3.3.6 Modifiers [string.view.modifiers]
constexpr void remove_prefix(size_type n);
// Preconditions: n <= size().
// Effects: Equivalent to: data_ += n; size_ -= n;
constexpr void remove_suffix(size_type n);
// Preconditions: n <= size(). Effects: Equivalent to: size_ -= n;
constexpr void swap(basic_string_view& s) noexcept;
// Effects: Exchanges the values of *this and s.
// 23.3.3.7 String operations [string.view.ops]
constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
// Let rlen be the smaller of n and size() - pos.
// Preconditions: [s, s + rlen) is a valid range.
// Effects: Equivalent to traits::copy(s, data() + pos, rlen). Returns: rlen.
// Throws: out_of_range if pos > size().
// Complexity: O(rlen).
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
// Let rlen be the smaller of n and size() - pos.
// Effects: Determines rlen, the effective length of the string to reference. Returns: basic_string_view(data() + pos, rlen).
// Throws: out_of_range if pos > size().
constexpr int compare(basic_string_view str) const noexcept;
// Let rlen be the smaller of size() and str.size().
// Effects: Determines rlen, the effective length of the strings to compare. The function then compares the two strings by calling traits::compare(data(), str.data(), rlen).
// Returns: The nonzero result if the result of the comparison is nonzero. Otherwise, returns a value as indicated in Table 76.
constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
// Effects: Equivalent to: return substr(pos1, n1).
compare(str);
constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
size_type pos2, size_type n2) const;
// Effects: Equivalent to: return substr(pos1, n1).compare(str.substr(pos2, n2)); constexpr int compare(const charT* s) const;
// Effects: Equivalent to:
return compare(basic_string_view(s));
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
// Effects: Equivalent to: return substr(pos1, n1).compare(basic_string_view(s)); constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
// Effects: Equivalent to: return substr(pos1, n1).compare(basic_string_view(s, n2)); constexpr bool starts_with(basic_string_view x) const noexcept;
// Effects: Equivalent to: return substr(0, x.size()) == x;
// — Each member function of the form
constexpr return-type F(const charT* s, size_type pos) const;
// has effects equivalent to:
return F (basic_string_view(s), pos);
// — Each member function of the form
constexpr return-type F(const charT* s, size_type pos, size_type n) const; // has effects equivalent to: return F (basic_string_view(s, n), pos);
// — Each member function of the form
constexpr return-type F(charT c, size_type pos) const noexcept;
// has effects equivalent to: return F (basic_string_view(addressof(c), 1), pos);
constexpr bool starts_with(charT x) const noexcept;
// Effects: Equivalent to: return !empty() && traits::eq(front(), x); constexpr bool starts_with(const charT* x) const;
// Effects: Equivalent to: return starts_with(basic_string_view(x));
constexpr bool ends_with(basic_string_view x) const noexcept;
// Effects: Equivalent to:
return size() >= x.size() && compare(size() - x.size(), npos, x) == 0;
constexpr bool ends_with(charT x) const noexcept;
// Effects: Equivalent to: return !empty() && traits::eq(back(), x); constexpr bool ends_with(const charT* x) const;
// Effects: Equivalent to: return ends_with(basic_string_view(x));
constexpr bool contains(basic_string_view x) const noexcept;
constexpr bool contains(charT x) const noexcept;
constexpr bool contains(const charT* x) const;
// Effects: Equivalent to: return find(x) != npos;
// 23.3.3.8 Searching [string.view.find]
// Member functions in this subclause have complexity O(size() * str.size()) at worst, although imple- mentations should do better.
// Let F be one of find, rfind, find_first_of, find_last_of, find_first_not_of, and find_last_not_of.
constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
// Let xpos be the lowest position, if possible, such that the following conditions hold:
// — pos <= xpos
// — xpos + str.size() <= size()
// — traits::eq(at(xpos + I), str.at(I)) for all elements I of the string referenced by str.
// Effects: Determines xpos.
// Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
// Let xpos be the highest position, if possible, such that the following conditions hold:
// — xpos <= pos
// — xpos + str.size() <= size()
// — traits::eq(at(xpos + I), str.at(I)) for all elements I of the string referenced by str.
// Effects: Determines xpos.
// Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
// Let xpos be the lowest position, if possible, such that the following conditions hold:
// — pos <= xpos
// — xpos < size()
// — traits::eq(at(xpos), str.at(I)) for some element I of the string referenced by str.
// Effects: Determines xpos.
// Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
// Let S be basic_string_view<charT, traits>, and sv be an instance of S. Implementations shall provide sufficient additional overloads marked constexpr and noexcept so that an object t with an implicit conversion to S can be compared according to Table 77.
// [Example 1: A sample conforming implementation for operator== would be:
constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
// Let xpos be the highest position, if possible, such that the following conditions hold:
// — xpos <= pos
// — xpos < size()
// — traits::eq(at(xpos), str.at(I)) for some element I of the string referenced by str.
// Effects: Determines xpos.
// Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
// Let xpos be the lowest position, if possible, such that the following conditions hold:
// — pos <= xpos
// — xpos < size()
// — traits::eq(at(xpos), str.at(I)) for no element I of the string referenced by str.
// Effects: Determines xpos.
// Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
// Let xpos be the highest position, if possible, such that the following conditions hold:
// — xpos <= pos
// — xpos < size()
// — traits::eq(at(xpos), str.at(I)) for no element I of the string referenced by str.
// Effects: Determines xpos.
// Returns: xpos if the function can determine such a value for xpos. Otherwise, returns npos.
// 23.3.4 Deduction guides [string.view.deduct]
template<class It, class End>
basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
// Constraints:
// — It satisfies contiguous_iterator.
// — End satisfies sized_sentinel_for<It>.
template<class R>
basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
// Constraints: R satisfies ranges::contiguous_range.
// 23.3.5 Non-member comparison functions [string.view.comparison]
template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> lhs,
basic_string_view<charT, traits> rhs) noexcept {
return lhs.compare(rhs) == 0;
}
template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> lhs,
type_identity_t<basic_string_view<charT, traits>> rhs) noexcept {
return lhs.compare(rhs) == 0;
}
template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> lhs,
basic_string_view<charT, traits> rhs) noexcept;
// Returns: lhs.compare(rhs) == 0.
template<class charT, class traits>
constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
basic_string_view<charT, traits> rhs) noexcept;
// Let R denote the type traits::comparison_category if that qualified-id is valid and denotes a type (13.10.3), otherwise R is weak_ordering.
// Mandates: R denotes a comparison category type (17.11.2). Returns: static_cast<R>(lhs.compare(rhs) <=> 0).
// 23.3.6 Inserters and extractors [string.view.io]
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, basic_string_view<charT, traits> str);
// Effects: Behaves as a formatted output function (31.7.5.3.1) of os. Forms a character sequence seq, initially consisting of the elements defined by the range [str.begin(), str.end()). Determines padding for seq as described in 31.7.5.3.1. Then inserts seq as if by calling os.rdbuf()->sputn(seq, n), where n is the larger of os.width() and str.size(); then calls os.width(0).
// Returns: os
// 23.3.7 Hash support [string.view.hash]
template<> struct hash<string_view>;
template<> struct hash<u8string_view>;
template<> struct hash<u16string_view>;
template<> struct hash<u32string_view>;
template<> struct hash<wstring_view>;
// The specialization is enabled (22.10.19).
// [Note 1: The hash value of a string view object is equal to the hash value of the corresponding string object (23.4.6).
// 23.3.8 Suffix for basic_string_view literals [string.view.literals]
constexpr string_view operator""sv(const char* str, size_t len) noexcept;
// Returns: string_view{str, len}.
constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept;
// Returns: u8string_view{str, len}.
constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
// Returns: u16string_view{str, len}.
constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
// Returns: u32string_view{str, len}.
constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
// Returns: wstring_view{str, len}.
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p798.cpp -std=03 -o p798l -I. -Wall
In file included from p798.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 \
^
p798.cpp:16:14: error: redefinition of 'n4910'
const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
^
p798.cpp:3:14: note: previous definition is here
const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
^
p798.cpp:31:55: error: a space is required between consecutive right angle brackets (use '> >')
template<class charT, class traits = char_traits<charT>> class basic_string_view;
^~
> >
p798.cpp:33:10: error: unknown type name 'constexpr'
inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
^
p798.cpp:33:25: error: use of undeclared identifier 'ranges'
inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
^
p798.cpp:35:10: error: unknown type name 'constexpr'
inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;
^
p798.cpp:35:25: error: use of undeclared identifier 'ranges'
inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;
^
p798.cpp:37:3: error: unknown type name 'constexpr'
constexpr bool operator==(basic_string_view<charT, traits> x,
^
p798.cpp:37:47: error: use of undeclared identifier 'charT'; did you mean 'char'?
constexpr bool operator==(basic_string_view<charT, traits> x,
^~~~~
char
p798.cpp:37:54: error: use of undeclared identifier 'traits'
constexpr bool operator==(basic_string_view<charT, traits> x,
^
p798.cpp:38:47: error: use of undeclared identifier 'charT'; did you mean 'char'?
basic_string_view<charT, traits> y) noexcept;
^~~~~
char
p798.cpp:38:54: error: use of undeclared identifier 'traits'
basic_string_view<charT, traits> y) noexcept;
^
p798.cpp:38:65: error: expected function body after function declarator
basic_string_view<charT, traits> y) noexcept;
^
p798.cpp:40:1: error: unknown type name 'constexpr'
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:40:11: warning: variable templates are a C++14 extension [-Wc++14-extensions]
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:40:14: error: expected ';' at end of declaration
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
;
p798.cpp:40:15: error: unknown type name 'below'
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:40:29: warning: '<=>' is a single token in C++20; add a space to avoid a change in behavior [-Wc++20-compat]
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:40:21: error: 'operator<=' cannot be the name of a variable or data member
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:40:31: error: expected ';' after top level declarator
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
;
p798.cpp:44:24: error: use of undeclared identifier 'charT'; did you mean 'char'?
basic_ostream<charT, traits>&
^~~~~
char
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
$ clang++ p798.cpp -std=2b -o p798l -I. -Wall
p798.cpp:16:14: error: redefinition of 'n4910'
const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
^
p798.cpp:3:14: note: previous definition is here
const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
^
p798.cpp:31:38: error: template parameter redefines default argument
template<class charT, class traits = char_traits<charT>> class basic_string_view;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/string_view:93:48: note: previous default template argument defined here
template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
^
p798.cpp:33:33: error: redefinition of 'enable_view<basic_string_view<charT, traits>>'
inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/string_view:758:2: note: previous definition is here
enable_view<basic_string_view<_CharT, _Traits>> = true;
^
p798.cpp:35:33: error: redefinition of 'enable_borrowed_range<basic_string_view<charT, traits>>'
inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/string_view:753:2: note: previous definition is here
enable_borrowed_range<basic_string_view<_CharT, _Traits>> = true;
^
p798.cpp:37:47: error: use of undeclared identifier 'charT'; did you mean 'char'?
constexpr bool operator==(basic_string_view<charT, traits> x,
^~~~~
char
p798.cpp:37:54: error: use of undeclared identifier 'traits'
constexpr bool operator==(basic_string_view<charT, traits> x,
^
p798.cpp:38:47: error: use of undeclared identifier 'charT'; did you mean 'char'?
basic_string_view<charT, traits> y) noexcept;
^~~~~
char
p798.cpp:38:54: error: use of undeclared identifier 'traits'
basic_string_view<charT, traits> y) noexcept;
^
p798.cpp:40:11: error: unknown type name 'see'
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:40:20: error: expected ';' at end of declaration
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
;
p798.cpp:40:51: error: use of undeclared identifier 'charT'; did you mean 'char'?
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^~~~~
char
p798.cpp:40:58: error: use of undeclared identifier 'traits'
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:41:53: error: use of undeclared identifier 'charT'; did you mean 'char'?
basic_string_view<charT, traits> y) noexcept;
^~~~~
char
p798.cpp:41:60: error: use of undeclared identifier 'traits'
basic_string_view<charT, traits> y) noexcept;
^
p798.cpp:40:21: error: C++ requires a type specifier for all declarations
constexpr see below operator<=>(basic_string_view<charT, traits> x,
^
p798.cpp:44:24: error: use of undeclared identifier 'charT'; did you mean 'char'?
basic_ostream<charT, traits>&
^~~~~
char
p798.cpp:44:31: error: use of undeclared identifier 'traits'
basic_ostream<charT, traits>&
^
p798.cpp:45:37: error: use of undeclared identifier 'charT'; did you mean 'char'?
operator<<(basic_ostream<charT, traits>& os,
^~~~~
char
p798.cpp:45:44: error: use of undeclared identifier 'traits'
operator<<(basic_ostream<charT, traits>& os,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p798.cpp -std=03 -o p798g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from N4910.h:11,
from p798.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 \
| ^~~~~
p798.cpp:33:10: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
33 | inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
| ^~~~~~~~~
p798.cpp:38:65: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
38 | basic_string_view<charT, traits> y) noexcept;
| ^~~~~~~~
p798.cpp:16:14: error: redefinition of 'const char* n4910'
16 | const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
| ^~~~~
p798.cpp:3:14: note: 'const char* n4910' previously defined here
3 | const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
| ^~~~~
p798.cpp:31:55: error: spurious '>>', use '>' to terminate a template argument list
31 | template<class charT, class traits = char_traits<charT>> class basic_string_view;
| ^~
p798.cpp:31:38: error: two or more data types in declaration of 'type name'
31 | template<class charT, class traits = char_traits<charT>> class basic_string_view;
| ^~~~~~~~~~~~~~~~~~~
p798.cpp:31:81: error: expected '>' before ';' token
31 | template<class charT, class traits = char_traits<charT>> class basic_string_view;
| ^
p798.cpp:31:81: error: expected unqualified-id before ';' token
p798.cpp:33:10: error: 'constexpr' does not name a type
33 | inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
| ^~~~~~~~~
p798.cpp:33:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:35:10: error: 'constexpr' does not name a type
35 | inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;
| ^~~~~~~~~
p798.cpp:35:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:37:3: error: 'constexpr' does not name a type
37 | constexpr bool operator==(basic_string_view<charT, traits> x,
| ^~~~~~~~~
p798.cpp:37:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:40:1: error: 'constexpr' does not name a type
40 | constexpr see below operator<=>(basic_string_view<charT, traits> x,
| ^~~~~~~~~
p798.cpp:40:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:44:24: error: 'charT' was not declared in this scope; did you mean 'char'?
44 | basic_ostream<charT, traits>&
| ^~~~~
| char
p798.cpp:44:31: error: 'traits' was not declared in this scope
44 | basic_ostream<charT, traits>&
| ^~~~~~
p798.cpp:44:37: error: template argument 1 is invalid
44 | basic_ostream<charT, traits>&
| ^
p798.cpp:44:37: error: template argument 2 is invalid
p798.cpp:45:37: error: 'charT' was not declared in this scope; did you mean 'char'?
45 | operator<<(basic_ostream<charT, traits>& os,
| ^~~~~
| char
p798.cpp:45:44: error: 'traits' was not declared in this scope
45 | operator<<(basic_ostream<charT, traits>& os,
| ^~~~~~
p798.cpp:45:50: error: template argument 1 is invalid
45 | operator<<(basic_ostream<charT, traits>& os,
| ^
p798.cpp:45:50: error: template argument 2 is invalid
p798.cpp:46:23: error: 'std::basic_string_view' is not a template
46 | basic_string_view<charT, traits> str);
| ^~~~~~~~~~~~~~~~~
p798.cpp:46:41: error: 'charT' was not declared in this scope; did you mean 'char'?
46 | basic_string_view<charT, traits> str);
| ^~~~~
| char
p798.cpp:46:48: error: 'traits' was not declared in this scope
46 | basic_string_view<charT, traits> str);
| ^~~~~~
p798.cpp:48:7: error: expected nested-name-specifier before 'string_view'
48 | using string_view = basic_string_view<char>; using u8string_view = basic_string_view<char8_t>; using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_view = basic_string_view<wchar_t>;
| ^~~~~~~~~~~
p798.cpp:48:52: error: expected nested-name-specifier before 'u8string_view'
48 | using string_view = basic_string_view<char>; using u8string_view = basic_string_view<char8_t>; using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_view = basic_string_view<wchar_t>;
| ^~~~~~~~~~~~~
p798.cpp:48:102: error: expected nested-name-specifier before 'u16string_view'
48 | g_view = basic_string_view<char>; using u8string_view = basic_string_view<char8_t>; using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_view = basic_string_view<wchar_t>;
| ^~~~~~~~~~~~~~
p798.cpp:48:154: error: expected nested-name-specifier before 'u32string_view'
48 | w = basic_string_view<char8_t>; using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_view = basic_string_view<wchar_t>;
| ^~~~~~~~~~~~~~
p798.cpp:48:206: error: expected nested-name-specifier before 'wstring_view'
48 | = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_vie = basic_string_view<wchar_t>;
| ^~~~~~~~~~~
p798.cpp:50:55: error: 'string_view' was not declared in this scope
50 | template<class T> struct hash; template<> struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^~~~~~~~~~~
p798.cpp:50:55: note: 'std::string_view' is only available from C++17 onwards
p798.cpp:50:66: error: template argument 1 is invalid
50 | template<class T> struct hash; template<> struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^
p798.cpp:50:92: error: 'u8string_view' was not declared in this scope; did you mean 'basic_string_view'?
50 | emplate<class T> struct hash; template<> struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^~~~~~~~~~~~~
| basic_string_view
p798.cpp:50:105: error: template argument 1 is invalid
50 | T> struct hash; template<> struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^
p798.cpp:50:131: error: 'u16string_view' was not declared in this scope; did you mean 'basic_string_view'?
50 | > struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^~~~~~~~~~~~~~
| basic_string_view
p798.cpp:50:145: error: template argument 1 is invalid
50 | string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^
p798.cpp:50:171: error: 'u32string_view' was not declared in this scope; did you mean 'basic_string_view'?
50 | truct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^~~~~~~~~~~~~~
| basic_string_view
p798.cpp:50:185: error: template argument 1 is invalid
50 | tring_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^
p798.cpp:50:211: error: 'wstring_view' was not declared in this scope
50 | ruct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_vie>;
| ^~~~~~~~~~~
p798.cpp:50:223: error: template argument 1 is invalid
50 | t hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>;
| ^
p798.cpp:54:1: error: 'constexpr' does not name a type
54 | constexpr string_view operator""sv(const char* str, size_t len) noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:54:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:54:75: error: 'constexpr' does not name a type
54 | constexpr string_view operator""sv(const char* str, size_t len) noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:54:75: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:54:154: error: 'constexpr' does not name a type
54 | noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:54:154: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:54:235: error: 'constexpr' does not name a type
54 | oexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:54:235: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:54:316: error: 'constexpr' does not name a type
54 | oexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:54:316: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:61:59: error: spurious '>>', use '>' to terminate a template argument list
61 | template<class charT, class traits = char_traits<charT>>
| ^~
p798.cpp:62:29: error: definition of 'class std::basic_string_view' inside template parameter list
62 | class basic_string_view {
| ^
p798.cpp:61:42: error: two or more data types in declaration of 'type name'
61 | template<class charT, class traits = char_traits<charT>>
| ^~~~~~~~~~~~~~~~~~~
p798.cpp:152:2: error: expected '>' before ';' token
152 | };
| ^
p798.cpp:152:2: error: expected unqualified-id before ';' token
p798.cpp:155:30: error: expected ')' before ',' token
155 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
| ~ ^
| )
p798.cpp:155:35: error: expected initializer before ')' token
155 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
| ^
p798.cpp:157:29: error: expected ')' before '&&' token
157 | basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
| ~ ^~
| )
p798.cpp:162:1: error: expected unqualified-id before '[' token
162 | [str.data(),str.data() + str.size())
| ^
p798.cpp:169:1: error: 'constexpr' does not name a type
169 | constexpr basic_string_view(const charT* str);
| ^~~~~~~~~
p798.cpp:169:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:173:1: error: 'constexpr' does not name a type
173 | constexpr basic_string_view(const charT* str, size_type len);
| ^~~~~~~~~
p798.cpp:173:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:177:9: error: 'constexpr' does not name a type
177 | constexpr basic_string_view(It begin, End end);
| ^~~~~~~~~
p798.cpp:177:9: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:186:3: error: 'constexpr' does not name a type
186 | constexpr basic_string_view(R&& r);
| ^~~~~~~~~
p798.cpp:186:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:194:7: error: expected nested-name-specifier before 'const_iterator'
194 | using const_iterator = implementation-defined;
| ^~~~~~~~~~~~~~
p798.cpp:197:1: error: 'constexpr' does not name a type
197 | constexpr const_iterator cbegin() const noexcept;
| ^~~~~~~~~
p798.cpp:197:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:201:1: error: 'constexpr' does not name a type
201 | constexpr const_iterator end() const noexcept;
| ^~~~~~~~~
p798.cpp:201:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:202:1: error: 'constexpr' does not name a type
202 | constexpr const_iterator cend() const noexcept;
| ^~~~~~~~~
p798.cpp:202:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:204:1: error: 'constexpr' does not name a type
204 | constexpr const_reverse_iterator rbegin() const noexcept;
| ^~~~~~~~~
p798.cpp:204:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:205:1: error: 'constexpr' does not name a type
205 | constexpr const_reverse_iterator crbegin() const noexcept;
| ^~~~~~~~~
p798.cpp:205:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:207:1: error: 'constexpr' does not name a type
207 | constexpr const_reverse_iterator rend() const noexcept;
| ^~~~~~~~~
p798.cpp:207:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:208:1: error: 'constexpr' does not name a type
208 | constexpr const_reverse_iterator crend() const noexcept;
| ^~~~~~~~~
p798.cpp:208:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:211:1: error: 'constexpr' does not name a type
211 | constexpr size_type size() const noexcept;
| ^~~~~~~~~
p798.cpp:211:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:212:1: error: 'constexpr' does not name a type
212 | constexpr size_type length() const noexcept;
| ^~~~~~~~~
p798.cpp:212:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:214:1: error: 'constexpr' does not name a type
214 | constexpr size_type max_size() const noexcept;
| ^~~~~~~~~
p798.cpp:214:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:216:1: error: expected unqualified-id before '[' token
216 | [[nodiscard]] constexpr bool empty() const noexcept;
| ^
p798.cpp:219:1: error: 'constexpr' does not name a type
219 | constexpr const_reference operator[](size_type pos) const;
| ^~~~~~~~~
p798.cpp:219:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:224:1: error: 'constexpr' does not name a type
224 | constexpr const_reference at(size_type pos) const;
| ^~~~~~~~~
p798.cpp:224:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:227:1: error: 'constexpr' does not name a type
227 | constexpr const_reference front() const;
| ^~~~~~~~~
p798.cpp:227:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:229:1: error: 'constexpr' does not name a type
229 | constexpr const_reference back() const;
| ^~~~~~~~~
p798.cpp:229:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:231:1: error: 'constexpr' does not name a type
231 | constexpr const_pointer data() const noexcept;
| ^~~~~~~~~
p798.cpp:231:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:235:1: error: 'constexpr' does not name a type
235 | constexpr void remove_prefix(size_type n);
| ^~~~~~~~~
p798.cpp:235:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:238:1: error: 'constexpr' does not name a type
238 | constexpr void remove_suffix(size_type n);
| ^~~~~~~~~
p798.cpp:238:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:240:1: error: 'constexpr' does not name a type
240 | constexpr void swap(basic_string_view& s) noexcept;
| ^~~~~~~~~
p798.cpp:240:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:243:1: error: 'constexpr' does not name a type
243 | constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
| ^~~~~~~~~
p798.cpp:243:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:249:1: error: 'constexpr' does not name a type
249 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
| ^~~~~~~~~
p798.cpp:249:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:253:1: error: 'constexpr' does not name a type
253 | constexpr int compare(basic_string_view str) const noexcept;
| ^~~~~~~~~
p798.cpp:253:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:257:1: error: 'constexpr' does not name a type
257 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
| ^~~~~~~~~
p798.cpp:257:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:259:8: error: expected constructor, destructor, or type conversion before '(' token
259 | compare(str);
| ^
p798.cpp:260:1: error: 'constexpr' does not name a type
260 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
| ^~~~~~~~~
p798.cpp:260:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:264:1: error: expected unqualified-id before 'return'
264 | return compare(basic_string_view(s));
| ^~~~~~
p798.cpp:265:1: error: 'constexpr' does not name a type
265 | constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
| ^~~~~~~~~
p798.cpp:265:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:270:1: error: 'constexpr' does not name a type
270 | constexpr return-type F(const charT* s, size_type pos) const;
| ^~~~~~~~~
p798.cpp:270:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:272:1: error: expected unqualified-id before 'return'
272 | return F (basic_string_view(s), pos);
| ^~~~~~
p798.cpp:274:1: error: 'constexpr' does not name a type
274 | constexpr return-type F(const charT* s, size_type pos, size_type n) const; // has effects equivalent to: return F (basic_string_view(s, n), pos);
| ^~~~~~~~~
p798.cpp:274:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:276:1: error: 'constexpr' does not name a type
276 | constexpr return-type F(charT c, size_type pos) const noexcept;
| ^~~~~~~~~
p798.cpp:276:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:278:1: error: 'constexpr' does not name a type
278 | constexpr bool starts_with(charT x) const noexcept;
| ^~~~~~~~~
p798.cpp:278:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:281:1: error: 'constexpr' does not name a type
281 | constexpr bool ends_with(basic_string_view x) const noexcept;
| ^~~~~~~~~
p798.cpp:281:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:283:1: error: expected unqualified-id before 'return'
283 | return size() >= x.size() && compare(size() - x.size(), npos, x) == 0;
| ^~~~~~
p798.cpp:284:1: error: 'constexpr' does not name a type
284 | constexpr bool ends_with(charT x) const noexcept;
| ^~~~~~~~~
p798.cpp:284:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:287:1: error: 'constexpr' does not name a type
287 | constexpr bool contains(basic_string_view x) const noexcept;
| ^~~~~~~~~
p798.cpp:287:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:288:1: error: 'constexpr' does not name a type
288 | constexpr bool contains(charT x) const noexcept;
| ^~~~~~~~~
p798.cpp:288:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:289:1: error: 'constexpr' does not name a type
289 | constexpr bool contains(const charT* x) const;
| ^~~~~~~~~
p798.cpp:289:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:294:1: error: 'constexpr' does not name a type
294 | constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
| ^~~~~~~~~
p798.cpp:294:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:301:1: error: 'constexpr' does not name a type
301 | constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
| ^~~~~~~~~
p798.cpp:301:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:308:1: error: 'constexpr' does not name a type
308 | constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
| ^~~~~~~~~
p798.cpp:308:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:317:1: error: 'constexpr' does not name a type
317 | constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
| ^~~~~~~~~
p798.cpp:317:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:324:1: error: 'constexpr' does not name a type
324 | constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
| ^~~~~~~~~
p798.cpp:324:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:331:1: error: 'constexpr' does not name a type
331 | constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
| ^~~~~~~~~
p798.cpp:331:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:340:23: error: expected ')' before ',' token
340 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
| ~ ^
| )
p798.cpp:345:22: error: expected ')' before '&&' token
345 | basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
| ~ ^~
| )
p798.cpp:349:5: error: 'constexpr' does not name a type
349 | constexpr bool operator==(basic_string_view<charT, traits> lhs,
| ^~~~~~~~~
p798.cpp:349:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:354:5: error: 'constexpr' does not name a type
354 | constexpr bool operator==(basic_string_view<charT, traits> lhs,
| ^~~~~~~~~
p798.cpp:354:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:359:3: error: 'constexpr' does not name a type
359 | constexpr bool operator==(basic_string_view<charT, traits> lhs,
| ^~~~~~~~~
p798.cpp:359:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:363:1: error: 'constexpr' does not name a type
363 | constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
| ^~~~~~~~~
p798.cpp:363:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:370:46: error: 'std::basic_string_view' is not a template
370 | operator<<(basic_ostream<charT, traits>& os, basic_string_view<charT, traits> str);
| ^~~~~~~~~~~~~~~~~
p798.cpp:374:24: error: 'string_view' was not declared in this scope
374 | template<> struct hash<string_view>;
| ^~~~~~~~~~~
p798.cpp:374:24: note: 'std::string_view' is only available from C++17 onwards
p798.cpp:374:35: error: template argument 1 is invalid
374 | template<> struct hash<string_view>;
| ^
p798.cpp:375:24: error: 'u8string_view' was not declared in this scope
375 | template<> struct hash<u8string_view>;
| ^~~~~~~~~~~~~
p798.cpp:375:37: error: template argument 1 is invalid
375 | template<> struct hash<u8string_view>;
| ^
p798.cpp:376:24: error: 'u16string_view' was not declared in this scope
376 | template<> struct hash<u16string_view>;
| ^~~~~~~~~~~~~~
p798.cpp:376:38: error: template argument 1 is invalid
376 | template<> struct hash<u16string_view>;
| ^
p798.cpp:377:24: error: 'u32string_view' was not declared in this scope
377 | template<> struct hash<u32string_view>;
| ^~~~~~~~~~~~~~
p798.cpp:377:38: error: template argument 1 is invalid
377 | template<> struct hash<u32string_view>;
| ^
p798.cpp:378:24: error: 'wstring_view' was not declared in this scope
378 | template<> struct hash<wstring_view>;
| ^~~~~~~~~~~~
p798.cpp:378:36: error: template argument 1 is invalid
378 | template<> struct hash<wstring_view>;
| ^
p798.cpp:382:1: error: 'constexpr' does not name a type
382 | constexpr string_view operator""sv(const char* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:382:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:384:1: error: 'constexpr' does not name a type
384 | constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:384:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:386:1: error: 'constexpr' does not name a type
386 | constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:386:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:388:1: error: 'constexpr' does not name a type
388 | constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:388:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p798.cpp:390:1: error: 'constexpr' does not name a type
390 | constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~~
p798.cpp:390:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
$ g++ p798.cpp -std=2b -o p798g -I. -Wall
p798.cpp:16:14: error: redefinition of 'const char* n4910'
16 | const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
| ^~~~~
p798.cpp:3:14: note: 'const char* n4910' previously defined here
3 | const char * n4910 = "23.3 String view classes [string.view] C++N4910:2022 (635) p798.cpp";
| ^~~~~
p798.cpp:31:23: error: redefinition of default argument for 'class traits'
31 | template<class charT, class traits = char_traits<charT>> class basic_string_view;
| ^~~~~
In file included from /usr/local/include/c++/12.1.0/bits/basic_string.h:48,
from /usr/local/include/c++/12.1.0/string:53,
from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
from /usr/local/include/c++/12.1.0/ios:42,
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 p798.cpp:10:
/usr/local/include/c++/12.1.0/string_view:99:29: note: original definition appeared here
99 | template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
| ^~~~~~~~
p798.cpp:33:25: error: redefinition of 'constexpr const bool std::ranges::enable_view<std::basic_string_view<_CharT, _Traits> >'
33 | inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
| ^~~~~~
/usr/local/include/c++/12.1.0/string_view:805:9: note: 'constexpr const bool std::ranges::enable_view<std::basic_string_view<_CharT, _Traits> >' previously declared here
805 | enable_view<basic_string_view<_CharT, _Traits>> = true;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p798.cpp:35:25: error: redefinition of 'constexpr const bool std::ranges::enable_borrowed_range<std::basic_string_view<_CharT, _Traits> >'
35 | inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;
| ^~~~~~
/usr/local/include/c++/12.1.0/string_view:800:9: note: 'constexpr const bool std::ranges::enable_borrowed_range<std::basic_string_view<_CharT, _Traits> >' previously declared here
800 | enable_borrowed_range<basic_string_view<_CharT, _Traits>> = true;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p798.cpp:37:47: error: 'charT' was not declared in this scope; did you mean 'char'?
37 | constexpr bool operator==(basic_string_view<charT, traits> x,
| ^~~~~
| char
p798.cpp:37:54: error: 'traits' was not declared in this scope
37 | constexpr bool operator==(basic_string_view<charT, traits> x,
| ^~~~~~
p798.cpp:37:60: error: template argument 1 is invalid
37 | constexpr bool operator==(basic_string_view<charT, traits> x,
| ^
p798.cpp:37:60: error: template argument 2 is invalid
p798.cpp:38:47: error: 'charT' was not declared in this scope; did you mean 'char'?
38 | basic_string_view<charT, traits> y) noexcept;
| ^~~~~
| char
p798.cpp:38:54: error: 'traits' was not declared in this scope
38 | basic_string_view<charT, traits> y) noexcept;
| ^~~~~~
p798.cpp:38:60: error: template argument 1 is invalid
38 | basic_string_view<charT, traits> y) noexcept;
| ^
p798.cpp:38:60: error: template argument 2 is invalid
p798.cpp:37:18: error: 'constexpr bool std::operator==(int, int)' must have an argument of class or enumerated type
37 | constexpr bool operator==(basic_string_view<charT, traits> x,
| ^~~~~~~~
p798.cpp:40:11: error: 'see' does not name a type
40 | constexpr see below operator<=>(basic_string_view<charT, traits> x,
| ^~~
p798.cpp:44:24: error: 'charT' was not declared in this scope; did you mean 'char'?
44 | basic_ostream<charT, traits>&
| ^~~~~
| char
p798.cpp:44:31: error: 'traits' was not declared in this scope
44 | basic_ostream<charT, traits>&
| ^~~~~~
p798.cpp:44:37: error: template argument 1 is invalid
44 | basic_ostream<charT, traits>&
| ^
p798.cpp:44:37: error: template argument 2 is invalid
p798.cpp:45:37: error: 'charT' was not declared in this scope; did you mean 'char'?
45 | operator<<(basic_ostream<charT, traits>& os,
| ^~~~~
| char
p798.cpp:45:44: error: 'traits' was not declared in this scope
45 | operator<<(basic_ostream<charT, traits>& os,
| ^~~~~~
p798.cpp:45:50: error: template argument 1 is invalid
45 | operator<<(basic_ostream<charT, traits>& os,
| ^
p798.cpp:45:50: error: template argument 2 is invalid
p798.cpp:46:41: error: 'charT' was not declared in this scope; did you mean 'char'?
46 | basic_string_view<charT, traits> str);
| ^~~~~
| char
p798.cpp:46:48: error: 'traits' was not declared in this scope
46 | basic_string_view<charT, traits> str);
| ^~~~~~
p798.cpp:46:54: error: template argument 1 is invalid
46 | basic_string_view<charT, traits> str);
| ^
p798.cpp:46:54: error: template argument 2 is invalid
p798.cpp:45:12: error: 'int& std::operator<<(int&, int)' must have an argument of class or enumerated type
45 | operator<<(basic_ostream<charT, traits>& os,
| ^~~~~~~~
p798.cpp:54:23: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
54 | constexpr string_view operator""sv(const char* str, size_t len) noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:54:99: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
54 | r string_view operator""sv(const char* str, size_t len) noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:54:179: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
54 | ring_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:54:260: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
54 | ing_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:54:339: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
54 | tring_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:61:27: error: redefinition of default argument for 'class traits'
61 | template<class charT, class traits = char_traits<charT>>
| ^~~~~
/usr/local/include/c++/12.1.0/string_view:99:29: note: original definition appeared here
99 | template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
| ^~~~~~~~
p798.cpp:155:30: error: expected ')' before ',' token
155 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
| ~ ^
| )
p798.cpp:155:35: error: expected initializer before ')' token
155 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
| ^
p798.cpp:162:1: error: expected unqualified-id before '[' token
162 | [str.data(),str.data() + str.size())
| ^
p798.cpp:169:35: error: 'charT' does not name a type; did you mean 'char'?
169 | constexpr basic_string_view(const charT* str);
| ^~~~~
| char
p798.cpp:169:1: error: 'decl-specifier' in declaration of deduction guide
169 | constexpr basic_string_view(const charT* str);
| ^~~~~~~~~
p798.cpp:169:11: error: deduction guide for 'std::basic_string_view<_CharT, _Traits>' must have trailing return type
169 | constexpr basic_string_view(const charT* str);
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: 'template<class _CharT, class _Traits> class std::basic_string_view' declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:173:35: error: 'charT' does not name a type; did you mean 'char'?
173 | constexpr basic_string_view(const charT* str, size_type len);
| ^~~~~
| char
p798.cpp:173:47: error: 'size_type' has not been declared
173 | constexpr basic_string_view(const charT* str, size_type len);
| ^~~~~~~~~
p798.cpp:173:1: error: 'decl-specifier' in declaration of deduction guide
173 | constexpr basic_string_view(const charT* str, size_type len);
| ^~~~~~~~~
p798.cpp:173:11: error: deduction guide for 'std::basic_string_view<_CharT, _Traits>' must have trailing return type
173 | constexpr basic_string_view(const charT* str, size_type len);
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: 'template<class _CharT, class _Traits> class std::basic_string_view' declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:177:9: error: 'decl-specifier' in declaration of deduction guide
177 | constexpr basic_string_view(It begin, End end);
| ^~~~~~~~~
p798.cpp:177:19: error: deduction guide for 'std::basic_string_view<_CharT, _Traits>' must have trailing return type
177 | constexpr basic_string_view(It begin, End end);
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: 'template<class _CharT, class _Traits> class std::basic_string_view' declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:186:3: error: 'decl-specifier' in declaration of deduction guide
186 | constexpr basic_string_view(R&& r);
| ^~~~~~~~~
p798.cpp:186:13: error: deduction guide for 'std::basic_string_view<_CharT, _Traits>' must have trailing return type
186 | constexpr basic_string_view(R&& r);
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: 'template<class _CharT, class _Traits> class std::basic_string_view' declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:194:24: error: 'implementation' does not name a type
194 | using const_iterator = implementation-defined;
| ^~~~~~~~~~~~~~
p798.cpp:197:11: error: 'const_iterator' does not name a type
197 | constexpr const_iterator cbegin() const noexcept;
| ^~~~~~~~~~~~~~
p798.cpp:201:11: error: 'const_iterator' does not name a type
201 | constexpr const_iterator end() const noexcept;
| ^~~~~~~~~~~~~~
p798.cpp:202:11: error: 'const_iterator' does not name a type
202 | constexpr const_iterator cend() const noexcept;
| ^~~~~~~~~~~~~~
p798.cpp:204:11: error: 'const_reverse_iterator' does not name a type
204 | constexpr const_reverse_iterator rbegin() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
p798.cpp:205:11: error: 'const_reverse_iterator' does not name a type
205 | constexpr const_reverse_iterator crbegin() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
p798.cpp:207:11: error: 'const_reverse_iterator' does not name a type
207 | constexpr const_reverse_iterator rend() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
p798.cpp:208:11: error: 'const_reverse_iterator' does not name a type
208 | constexpr const_reverse_iterator crend() const noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~
p798.cpp:211:11: error: 'size_type' does not name a type; did you mean 'size_t'?
211 | constexpr size_type size() const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:212:11: error: 'size_type' does not name a type; did you mean 'size_t'?
212 | constexpr size_type length() const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:214:11: error: 'size_type' does not name a type; did you mean 'size_t'?
214 | constexpr size_type max_size() const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:216:44: error: non-member function 'constexpr bool empty()' cannot have cv-qualifier
216 | [[nodiscard]] constexpr bool empty() const noexcept;
| ^~~~~~~~
p798.cpp:219:11: error: 'const_reference' does not name a type
219 | constexpr const_reference operator[](size_type pos) const;
| ^~~~~~~~~~~~~~~
p798.cpp:224:11: error: 'const_reference' does not name a type
224 | constexpr const_reference at(size_type pos) const;
| ^~~~~~~~~~~~~~~
p798.cpp:227:11: error: 'const_reference' does not name a type
227 | constexpr const_reference front() const;
| ^~~~~~~~~~~~~~~
p798.cpp:229:11: error: 'const_reference' does not name a type
229 | constexpr const_reference back() const;
| ^~~~~~~~~~~~~~~
p798.cpp:231:11: error: 'const_pointer' does not name a type
231 | constexpr const_pointer data() const noexcept;
| ^~~~~~~~~~~~~
p798.cpp:235:16: error: variable or field 'remove_prefix' declared void
235 | constexpr void remove_prefix(size_type n);
| ^~~~~~~~~~~~~
p798.cpp:235:30: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
235 | constexpr void remove_prefix(size_type n);
| ^~~~~~~~~
| size_t
p798.cpp:238:16: error: variable or field 'remove_suffix' declared void
238 | constexpr void remove_suffix(size_type n);
| ^~~~~~~~~~~~~
p798.cpp:238:30: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
238 | constexpr void remove_suffix(size_type n);
| ^~~~~~~~~
| size_t
p798.cpp:240:21: error: template placeholder type 'basic_string_view<...auto...>' must be followed by a simple declarator-id
240 | constexpr void swap(basic_string_view& s) noexcept;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: 'template<class _CharT, class _Traits> class std::basic_string_view' declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:243:11: error: 'size_type' does not name a type; did you mean 'size_t'?
243 | constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
| ^~~~~~~~~
| size_t
p798.cpp:249:36: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
249 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
| ^~~~~~~~~
| size_t
p798.cpp:249:55: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
249 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
| ^~~~~~~~~
| size_t
p798.cpp:249:75: error: expected ',' or ';' before 'const'
249 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
| ^~~~~
p798.cpp:253:23: error: class template placeholder 'std::basic_string_view' not permitted in this context
253 | constexpr int compare(basic_string_view str) const noexcept;
| ^~~~~~~~~~~~~~~~~
p798.cpp:253:23: note: use 'auto' for an abbreviated function template
p798.cpp:253:52: error: non-member function 'constexpr int compare(...)' cannot have cv-qualifier
253 | constexpr int compare(basic_string_view str) const noexcept;
| ^~~~~~~~
p798.cpp:257:23: error: 'constexpr const int compare' redeclared as different kind of entity
257 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
| ^~~~~~~~~
p798.cpp:253:15: note: previous declaration 'constexpr int compare(...)'
253 | constexpr int compare(basic_string_view str) const noexcept;
| ^~~~~~~
p798.cpp:257:23: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
257 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
| ^~~~~~~~~
| size_t
p798.cpp:257:39: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
257 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
| ^~~~~~~~~
| size_t
p798.cpp:257:71: error: missing template arguments before 'str'
257 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
| ^~~
p798.cpp:259:8: error: expected constructor, destructor, or type conversion before '(' token
259 | compare(str);
| ^
p798.cpp:260:23: error: 'constexpr const int compare' redeclared as different kind of entity
260 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
| ^~~~~~~~~
p798.cpp:253:15: note: previous declaration 'constexpr int compare(...)'
253 | constexpr int compare(basic_string_view str) const noexcept;
| ^~~~~~~
p798.cpp:260:23: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
260 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
| ^~~~~~~~~
| size_t
p798.cpp:260:39: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
260 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
| ^~~~~~~~~
| size_t
p798.cpp:260:71: error: missing template arguments before 'str'
260 | constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
| ^~~
p798.cpp:261:23: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
261 | size_type pos2, size_type n2) const;
| ^~~~~~~~~
| size_t
p798.cpp:261:39: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
261 | size_type pos2, size_type n2) const;
| ^~~~~~~~~
| size_t
p798.cpp:264:1: error: expected unqualified-id before 'return'
264 | return compare(basic_string_view(s));
| ^~~~~~
p798.cpp:265:23: error: 'constexpr const int compare' redeclared as different kind of entity
265 | constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
| ^~~~~~~~~
p798.cpp:253:15: note: previous declaration 'constexpr int compare(...)'
253 | constexpr int compare(basic_string_view str) const noexcept;
| ^~~~~~~
p798.cpp:265:23: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
265 | constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
| ^~~~~~~~~
| size_t
p798.cpp:265:39: error: 'size_type' was not declared in this scope; did you mean 'size_t'?
265 | constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
| ^~~~~~~~~
| size_t
p798.cpp:265:53: error: expected primary-expression before 'const'
265 | constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
| ^~~~~
p798.cpp:270:11: error: expected unqualified-id before 'return'
270 | constexpr return-type F(const charT* s, size_type pos) const;
| ^~~~~~
p798.cpp:272:1: error: expected unqualified-id before 'return'
272 | return F (basic_string_view(s), pos);
| ^~~~~~
p798.cpp:274:11: error: expected unqualified-id before 'return'
274 | constexpr return-type F(const charT* s, size_type pos, size_type n) const; // has effects equivalent to: return F (basic_string_view(s, n), pos);
| ^~~~~~
p798.cpp:276:11: error: expected unqualified-id before 'return'
276 | constexpr return-type F(charT c, size_type pos) const noexcept;
| ^~~~~~
p798.cpp:278:28: error: 'charT' was not declared in this scope; did you mean 'char'?
278 | constexpr bool starts_with(charT x) const noexcept;
| ^~~~~
| char
p798.cpp:281:26: error: class template placeholder 'std::basic_string_view' not permitted in this context
281 | constexpr bool ends_with(basic_string_view x) const noexcept;
| ^~~~~~~~~~~~~~~~~
p798.cpp:281:26: note: use 'auto' for an abbreviated function template
p798.cpp:281:53: error: non-member function 'constexpr bool ends_with(...)' cannot have cv-qualifier
281 | constexpr bool ends_with(basic_string_view x) const noexcept;
| ^~~~~~~~
p798.cpp:283:1: error: expected unqualified-id before 'return'
283 | return size() >= x.size() && compare(size() - x.size(), npos, x) == 0;
| ^~~~~~
p798.cpp:284:26: error: 'constexpr const bool ends_with' redeclared as different kind of entity
284 | constexpr bool ends_with(charT x) const noexcept;
| ^~~~~
p798.cpp:281:16: note: previous declaration 'constexpr bool ends_with(...)'
281 | constexpr bool ends_with(basic_string_view x) const noexcept;
| ^~~~~~~~~
p798.cpp:284:26: error: 'charT' was not declared in this scope; did you mean 'char'?
284 | constexpr bool ends_with(charT x) const noexcept;
| ^~~~~
| char
p798.cpp:287:25: error: class template placeholder 'std::basic_string_view' not permitted in this context
287 | constexpr bool contains(basic_string_view x) const noexcept;
| ^~~~~~~~~~~~~~~~~
p798.cpp:287:25: note: use 'auto' for an abbreviated function template
p798.cpp:287:52: error: non-member function 'constexpr bool contains(...)' cannot have cv-qualifier
287 | constexpr bool contains(basic_string_view x) const noexcept;
| ^~~~~~~~
p798.cpp:288:25: error: 'constexpr const bool contains' redeclared as different kind of entity
288 | constexpr bool contains(charT x) const noexcept;
| ^~~~~
p798.cpp:287:16: note: previous declaration 'constexpr bool contains(...)'
287 | constexpr bool contains(basic_string_view x) const noexcept;
| ^~~~~~~~
p798.cpp:288:25: error: 'charT' was not declared in this scope; did you mean 'char'?
288 | constexpr bool contains(charT x) const noexcept;
| ^~~~~
| char
p798.cpp:289:31: error: 'charT' does not name a type; did you mean 'char'?
289 | constexpr bool contains(const charT* x) const;
| ^~~~~
| char
p798.cpp:289:41: error: non-member function 'constexpr bool contains(const int*)' cannot have cv-qualifier
289 | constexpr bool contains(const charT* x) const;
| ^~~~~
p798.cpp:294:11: error: 'size_type' does not name a type; did you mean 'size_t'?
294 | constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:301:11: error: 'size_type' does not name a type; did you mean 'size_t'?
301 | constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:308:11: error: 'size_type' does not name a type; did you mean 'size_t'?
308 | constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:317:11: error: 'size_type' does not name a type; did you mean 'size_t'?
317 | constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:324:11: error: 'size_type' does not name a type; did you mean 'size_t'?
324 | constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:331:11: error: 'size_type' does not name a type; did you mean 'size_t'?
331 | constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
| ^~~~~~~~~
| size_t
p798.cpp:340:3: error: deduction guide 'basic_string_view(It, End)-> std::basic_string_view<typename std::__detail::__iter_traits_impl<typename std::remove_cvref<_Tp>::type, std::indirectly_readable_traits<typename std::remove_cvref<_Tp>::type> >::type::value_type>' must be declared in the same scope as 'std::basic_string_view<_CharT, _Traits>'
340 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:345:3: error: deduction guide 'basic_string_view(R&&)-> std::basic_string_view<std::ranges::range_value_t<_Range> >' must be declared in the same scope as 'std::basic_string_view<_CharT, _Traits>'
345 | basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/string_view:100:11: note: declared here
100 | class basic_string_view
| ^~~~~~~~~~~~~~~~~
p798.cpp:363:11: error: 'see' does not name a type
363 | constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
| ^~~
p798.cpp:374:19: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
374 | template<> struct hash<string_view>;
| ^~~~~~~~~~~~~~~~~
p798.cpp:375:19: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
375 | template<> struct hash<u8string_view>;
| ^~~~~~~~~~~~~~~~~~~
p798.cpp:376:19: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
376 | template<> struct hash<u16string_view>;
| ^~~~~~~~~~~~~~~~~~~~
p798.cpp:377:19: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
377 | template<> struct hash<u32string_view>;
| ^~~~~~~~~~~~~~~~~~~~
p798.cpp:378:19: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
378 | template<> struct hash<wstring_view>;
| ^~~~~~~~~~~~~~~~~~
p798.cpp:382:23: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
382 | constexpr string_view operator""sv(const char* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:384:25: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
384 | constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:386:26: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
386 | constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:388:26: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
388 | constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:390:24: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
390 | constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
| ^~~~~~~~
p798.cpp:249:29: warning: 'substr' defined but not used [-Wunused-variable]
249 | constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
| ^~~~~~
検討事項(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 初稿 20220804