diff --git a/reference/iterator/basic_const_iterator.md b/reference/iterator/basic_const_iterator.md index a6d62a285..74b56deb4 100644 --- a/reference/iterator/basic_const_iterator.md +++ b/reference/iterator/basic_const_iterator.md @@ -32,10 +32,10 @@ namespace std { | [`operator[]`](basic_const_iterator/op_at.md) | 任意の位置にランダムアクセスする | C++23 | | [`operator==`](basic_const_iterator/op_equal.md) | 等値比較 | C++23 | | `operator!=` | 非等値比較 ([`==`](basic_const_iterator/op_equal.md)により使用可能) | C++23 | -| [`operator<`](basic_const_iterator/op_less.md.nolink) | 左辺が右辺より小さいかの判定を行う | C++23 | -| [`operator<=`](basic_const_iterator/op_less_equal.md.nolink) | 左辺が右辺以下かの判定を行う | C++23 | -| [`operator>`](basic_const_iterator/op_greater.md.nolink) | 左辺が右辺より大きいかの判定を行う | C++23 | -| [`operator>=`](basic_const_iterator/op_greater_equal.md.nolink) | 左辺が右辺以上かの判定を行う | C++23 | +| [`operator<`](basic_const_iterator/op_less.md) | 左辺が右辺より小さいかの判定を行う | C++23 | +| [`operator<=`](basic_const_iterator/op_less_equal.md) | 左辺が右辺以下かの判定を行う | C++23 | +| [`operator>`](basic_const_iterator/op_greater.md) | 左辺が右辺より大きいかの判定を行う | C++23 | +| [`operator>=`](basic_const_iterator/op_greater_equal.md) | 左辺が右辺以上かの判定を行う | C++23 | | [`operator<=>`](basic_const_iterator/op_compare_3way.md) | 三方比較を行う | C++23 | @@ -65,10 +65,10 @@ namespace std { | 名前 | 説明 | 対応バージョン | |------------------------------------------------------|-------------|-------| -| [`operator<`](basic_const_iterator/op_less.md.nolink) | 左辺が右辺より小さいかの判定を行う | C++23 | -| [`operator<=`](basic_const_iterator/op_less_equal.md.nolink) | 左辺が右辺以下かの判定を行う | C++23 | -| [`operator>`](basic_const_iterator/op_greater.md.nolink) | 左辺が右辺より大きいかの判定を行う | C++23 | -| [`operator>=`](basic_const_iterator/op_greater_equal.md.nolink) | 左辺が右辺以上かの判定を行う | C++23 | +| [`operator<`](basic_const_iterator/op_less.md) | 左辺が右辺より小さいかの判定を行う | C++23 | +| [`operator<=`](basic_const_iterator/op_less_equal.md) | 左辺が右辺以下かの判定を行う | C++23 | +| [`operator>`](basic_const_iterator/op_greater.md) | 左辺が右辺より大きいかの判定を行う | C++23 | +| [`operator>=`](basic_const_iterator/op_greater_equal.md) | 左辺が右辺以上かの判定を行う | C++23 | | [`operator+`](basic_const_iterator/op_plus.md) | イテレータを進める | C++23 | | [`operator-`](basic_const_iterator/op_unary_minus.md) | イテレータを逆に進める | C++23 | | [`operator-`](basic_const_iterator/op_minus.md) | 2つの`basic_const_iterator`の差を求める | C++23 | diff --git a/reference/iterator/basic_const_iterator/op_greater.md b/reference/iterator/basic_const_iterator/op_greater.md new file mode 100644 index 000000000..9feb50dd9 --- /dev/null +++ b/reference/iterator/basic_const_iterator/op_greater.md @@ -0,0 +1,108 @@ +# operator> +* iterator[meta header] +* std[meta namespace] +* basic_const_iterator[meta class] +* function[meta id-type] +* cpp23[meta cpp] + +```cpp +constexpr bool operator>(const basic_const_iterator& y) const + requires random_access_iterator; // (1) + +template I> +constexpr bool operator>(const I& y) const + requires random_access_iterator && totally_ordered_with; // (2) + +template +friend constexpr bool operator>(const I& x, const basic_const_iterator& y) + requires random_access_iterator && totally_ordered_with; // (3) 非メンバ関数 +``` +* random_access_iterator[link /reference/iterator/random_access_iterator.md] +* totally_ordered_with[link /reference/concepts/totally_ordered.md] +* different-from[link /reference/ranges/different-from.md] + +## 概要 + +`basic_const_iterator`オブジェクト同士あるいは別のイテレータとの間で、左辺が右辺より大きいかを判定する。 + +- (1) : 同じ`random_access_iterator`特殊化同士の間の`>`比較 +- (2) : `Iterator`と比較可能な型の値との間の`>`比較 +- (3) : (2)の逆順の演算子 + +## テンプレートパラメータ制約 + +`not-a-const-iterator`は`I`が`basic_const_iterator`の特殊化ではない場合に`true`となる説明専用のコンセプトである。 + +## 効果 + +ラップしているイテレータを`current_`メンバ変数に保持するとして、以下と等価 + +- (1) : 以下と等価 + ```cpp + return current_ > y.current_; + ``` + +- (2) : 以下と等価 + ```cpp + return current_ > y; + ``` + +- (3) : 以下と等価 + ```cpp + return x > y.current_; + ``` + +## 備考 + +(3)の関数は[*Hidden friends*](/article/lib/hidden_friends.md)として定義される。 + +## 例 +```cpp example +#include +#include +#include + +int main() { + std::vector vec = {1, 2, 3, 4, 5}; + + std::basic_const_iterator cit = vec.begin(); + auto se = vec.end(); + std::basic_const_iterator cse = se; + + std::cout << std::boolalpha; + + // basic_const_iterator同士の比較 + std::cout << (cit > cse) << '\n'; + std::cout << (cse > cit) << '\n'; + std::cout << (cit > cit) << '\n'; + + // 元のイテレータとの比較 + std::cout << (cit > se) << '\n'; + std::cout << (se > cit) << '\n'; + std::cout << (cit > cit.base()) << '\n'; +} +``` +* >[color ff0000] + +### 出力 +``` +false +true +false +false +true +false +``` + +## バージョン +### 言語 +- C++23 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): 13.1 +- [Visual C++](/implementation.md#visual_cpp): 2022 Update 6 + +## 参照 + +- [P2278R4 `cbegin` should always return a constant iterator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2278r4.html) diff --git a/reference/iterator/basic_const_iterator/op_greater_equal.md b/reference/iterator/basic_const_iterator/op_greater_equal.md new file mode 100644 index 000000000..30d4283c7 --- /dev/null +++ b/reference/iterator/basic_const_iterator/op_greater_equal.md @@ -0,0 +1,108 @@ +# operator>= +* iterator[meta header] +* std[meta namespace] +* basic_const_iterator[meta class] +* function[meta id-type] +* cpp23[meta cpp] + +```cpp +constexpr bool operator>=(const basic_const_iterator& y) const + requires random_access_iterator; // (1) + +template I> +constexpr bool operator>=(const I& y) const + requires random_access_iterator && totally_ordered_with; // (2) + +template +friend constexpr bool operator>=(const I& x, const basic_const_iterator& y) + requires random_access_iterator && totally_ordered_with; // (3) 非メンバ関数 +``` +* random_access_iterator[link /reference/iterator/random_access_iterator.md] +* totally_ordered_with[link /reference/concepts/totally_ordered.md] +* different-from[link /reference/ranges/different-from.md] + +## 概要 + +`basic_const_iterator`オブジェクト同士あるいは別のイテレータとの間で、左辺が右辺以上かを判定する。 + +- (1) : 同じ`random_access_iterator`特殊化同士の間の`>=`比較 +- (2) : `Iterator`と比較可能な型の値との間の`>=`比較 +- (3) : (2)の逆順の演算子 + +## テンプレートパラメータ制約 + +`not-a-const-iterator`は`I`が`basic_const_iterator`の特殊化ではない場合に`true`となる説明専用のコンセプトである。 + +## 効果 + +ラップしているイテレータを`current_`メンバ変数に保持するとして、以下と等価 + +- (1) : 以下と等価 + ```cpp + return current_ >= y.current_; + ``` + +- (2) : 以下と等価 + ```cpp + return current_ >= y; + ``` + +- (3) : 以下と等価 + ```cpp + return x >= y.current_; + ``` + +## 備考 + +(3)の関数は[*Hidden friends*](/article/lib/hidden_friends.md)として定義される。 + +## 例 +```cpp example +#include +#include +#include + +int main() { + std::vector vec = {1, 2, 3, 4, 5}; + + std::basic_const_iterator cit = vec.begin(); + auto se = vec.end(); + std::basic_const_iterator cse = se; + + std::cout << std::boolalpha; + + // basic_const_iterator同士の比較 + std::cout << (cit >= cse) << '\n'; + std::cout << (cse >= cit) << '\n'; + std::cout << (cit >= cit) << '\n'; + + // 元のイテレータとの比較 + std::cout << (cit >= se) << '\n'; + std::cout << (se >= cit) << '\n'; + std::cout << (cit >= cit.base()) << '\n'; +} +``` +* >=[color ff0000] + +### 出力 +``` +false +true +true +false +true +true +``` + +## バージョン +### 言語 +- C++23 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): 13.1 +- [Visual C++](/implementation.md#visual_cpp): 2022 Update 6 + +## 参照 + +- [P2278R4 `cbegin` should always return a constant iterator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2278r4.html) diff --git a/reference/iterator/basic_const_iterator/op_less.md b/reference/iterator/basic_const_iterator/op_less.md new file mode 100644 index 000000000..dcc2b4009 --- /dev/null +++ b/reference/iterator/basic_const_iterator/op_less.md @@ -0,0 +1,108 @@ +# operator< +* iterator[meta header] +* std[meta namespace] +* basic_const_iterator[meta class] +* function[meta id-type] +* cpp23[meta cpp] + +```cpp +constexpr bool operator<(const basic_const_iterator& y) const + requires random_access_iterator; // (1) + +template I> +constexpr bool operator<(const I& y) const + requires random_access_iterator && totally_ordered_with; // (2) + +template +friend constexpr bool operator<(const I& x, const basic_const_iterator& y) + requires random_access_iterator && totally_ordered_with; // (3) 非メンバ関数 +``` +* random_access_iterator[link /reference/iterator/random_access_iterator.md] +* totally_ordered_with[link /reference/concepts/totally_ordered.md] +* different-from[link /reference/ranges/different-from.md] + +## 概要 + +`basic_const_iterator`オブジェクト同士あるいは別のイテレータとの間で、左辺が右辺より小さいかを判定する。 + +- (1) : 同じ`random_access_iterator`特殊化同士の間の`<`比較 +- (2) : `Iterator`と比較可能な型の値との間の`<`比較 +- (3) : (2)の逆順の演算子 + +## テンプレートパラメータ制約 + +`not-a-const-iterator`は`I`が`basic_const_iterator`の特殊化ではない場合に`true`となる説明専用のコンセプトである。 + +## 効果 + +ラップしているイテレータを`current_`メンバ変数に保持するとして、以下と等価 + +- (1) : 以下と等価 + ```cpp + return current_ < y.current_; + ``` + +- (2) : 以下と等価 + ```cpp + return current_ < y; + ``` + +- (3) : 以下と等価 + ```cpp + return x < y.current_; + ``` + +## 備考 + +(3)の関数は[*Hidden friends*](/article/lib/hidden_friends.md)として定義される。 + +## 例 +```cpp example +#include +#include +#include + +int main() { + std::vector vec = {1, 2, 3, 4, 5}; + + std::basic_const_iterator cit = vec.begin(); + auto se = vec.end(); + std::basic_const_iterator cse = se; + + std::cout << std::boolalpha; + + // basic_const_iterator同士の比較 + std::cout << (cit < cse) << '\n'; + std::cout << (cse < cit) << '\n'; + std::cout << (cit < cit) << '\n'; + + // 元のイテレータとの比較 + std::cout << (cit < se) << '\n'; + std::cout << (se < cit) << '\n'; + std::cout << (cit < cit.base()) << '\n'; +} +``` +* <[color ff0000] + +### 出力 +``` +true +false +false +true +false +false +``` + +## バージョン +### 言語 +- C++23 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): 13.1 +- [Visual C++](/implementation.md#visual_cpp): 2022 Update 6 + +## 参照 + +- [P2278R4 `cbegin` should always return a constant iterator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2278r4.html) diff --git a/reference/iterator/basic_const_iterator/op_less_equal.md b/reference/iterator/basic_const_iterator/op_less_equal.md new file mode 100644 index 000000000..2dd0ba407 --- /dev/null +++ b/reference/iterator/basic_const_iterator/op_less_equal.md @@ -0,0 +1,108 @@ +# operator<= +* iterator[meta header] +* std[meta namespace] +* basic_const_iterator[meta class] +* function[meta id-type] +* cpp23[meta cpp] + +```cpp +constexpr bool operator<=(const basic_const_iterator& y) const + requires random_access_iterator; // (1) + +template I> +constexpr bool operator<=(const I& y) const + requires random_access_iterator && totally_ordered_with; // (2) + +template +friend constexpr bool operator<=(const I& x, const basic_const_iterator& y) + requires random_access_iterator && totally_ordered_with; // (3) 非メンバ関数 +``` +* random_access_iterator[link /reference/iterator/random_access_iterator.md] +* totally_ordered_with[link /reference/concepts/totally_ordered.md] +* different-from[link /reference/ranges/different-from.md] + +## 概要 + +`basic_const_iterator`オブジェクト同士あるいは別のイテレータとの間で、、左辺が右辺以下かを判定する。 + +- (1) : 同じ`random_access_iterator`特殊化同士の間の`<=`比較 +- (2) : `Iterator`と比較可能な型の値との間の`<=`比較 +- (3) : (2)の逆順の演算子 + +## テンプレートパラメータ制約 + +`not-a-const-iterator`は`I`が`basic_const_iterator`の特殊化ではない場合に`true`となる説明専用のコンセプトである。 + +## 効果 + +ラップしているイテレータを`current_`メンバ変数に保持するとして、以下と等価 + +- (1) : 以下と等価 + ```cpp + return current_ <= y.current_; + ``` + +- (2) : 以下と等価 + ```cpp + return current_ <= y; + ``` + +- (3) : 以下と等価 + ```cpp + return x <= y.current_; + ``` + +## 備考 + +(3)の関数は[*Hidden friends*](/article/lib/hidden_friends.md)として定義される。 + +## 例 +```cpp example +#include +#include +#include + +int main() { + std::vector vec = {1, 2, 3, 4, 5}; + + std::basic_const_iterator cit = vec.begin(); + auto se = vec.end(); + std::basic_const_iterator cse = se; + + std::cout << std::boolalpha; + + // basic_const_iterator同士の比較 + std::cout << (cit <= cse) << '\n'; + std::cout << (cse <= cit) << '\n'; + std::cout << (cit <= cit) << '\n'; + + // 元のイテレータとの比較 + std::cout << (cit <= se) << '\n'; + std::cout << (se <= cit) << '\n'; + std::cout << (cit <= cit.base()) << '\n'; +} +``` +* <=[color ff0000] + +### 出力 +``` +true +false +true +true +false +true +``` + +## バージョン +### 言語 +- C++23 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): 13.1 +- [Visual C++](/implementation.md#visual_cpp): 2022 Update 6 + +## 参照 + +- [P2278R4 `cbegin` should always return a constant iterator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2278r4.html)