Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/script/ngword_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ def check_ngword(text: str, filename: str) -> bool:
found_error = True
return not found_error

# 名前付きHTMLエンティティ(√   × 等)は、CIのビルドが
# 生成HTMLをXMLとしてパースする際に "undefined entity" エラーになる。
# XMLで有効なのは & < > " ' と数値文字参照 &#...; のみ。
# 数値文字参照(√ 等)か、実際のUnicode文字(√ 等)を使うこと。
NAMED_HTML_ENTITY_RE = re.compile(r'&(?!(?:amp|lt|gt|quot|apos);|#)[A-Za-z][A-Za-z0-9]*;')

def remove_code(text: str) -> str:
# コード中の `return &x;` 等を誤検出しないよう、コードブロック/インラインコードを除去する
text = re.sub(r'```.*?```', '', text, flags=re.DOTALL)
text = re.sub(r'`[^`]*`', '', text)
return text

def check_named_html_entity(text: str, filename: str) -> bool:
found_error: bool = False
for m in NAMED_HTML_ENTITY_RE.finditer(remove_code(text)):
print("{}: the file includes a named HTML entity \"{}\" which is undefined in the XML build. use a numeric character reference instead (e.g. \"√\" for √, \" \" for nbsp).".format(filename, m.group(0)))
found_error = True
return not found_error

def check() -> bool:
found_error = False
for p in sorted(list(glob.glob("**/*.md", recursive=True))):
Expand All @@ -90,6 +109,9 @@ def check() -> bool:
if not check_ngword(text, p):
found_error = True

if not check_named_html_entity(text, p):
found_error = True

return not found_error

if __name__ == '__main__':
Expand Down
2 changes: 2 additions & 0 deletions GLOBAL_QUALIFY_LIST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
* std::endl[link /reference/ostream/endl.md]
* <print>[link /reference/print.md]
* std::println[link /reference/print/println.md]
* std::print[link /reference/print/print.md]
* <queue>[link /reference/queue.md]
* <random>[link /reference/random.md]
* std::default_random_engine[link /reference/random/default_random_engine.md]
Expand Down Expand Up @@ -310,6 +311,7 @@
* <set>[link /reference/set.md]
* std::set[link /reference/set/set.md]
* <shared_mutex>[link /reference/shared_mutex.md]
* <simd>[link /reference/simd.md]
* <source_location>[link /reference/source_location.md]
* std::source_location[link /reference/source_location/source_location.md]
* <span>[link /reference/span.md]
Expand Down
2 changes: 1 addition & 1 deletion lang/cpp26.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ C++26とは、2026年中に改訂される予定の、C++バージョンの通
- 要素のメモリ位置が安定するシーケンスコンテナのライブラリとして[`<hive>`](/reference/hive.md)を追加
- 並行処理におけるデータの参照・更新を行うRCU (Read Copy Update) のライブラリとして、[`<rcu>`](/reference/rcu.md)を追加
- 並行処理において参照中のデータが更新されないよう保護するハザードポインタのライブラリとして、[`<hazard_pointer>`](/reference/hazard_pointer.md.nolink)を追加
- データ並列ライブラリとして、[`<simd>`](/reference/simd.md.nolink)を追加
- データ並列ライブラリとして、[`<simd>`](/reference/simd.md)を追加
- デバッグサポートのライブラリとして[`<debugging>`](/reference/debugging.md)を追加
- 線形代数ライブラリとして[`<linalg>`](/reference/linalg.md)を追加
- コンパイル時に容量を固定する可変長配列クラスのライブラリとして[`<inplace_vector>`](/reference/inplace_vector.md)を追加
Expand Down
6 changes: 3 additions & 3 deletions lang/cpp26/feature_test_macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
|`__cpp_lib_reflection`|`202506L`|[静的リフレクション](/lang/cpp26/reflection.md)のライブラリ機能|[`<meta>`](/reference/meta.md)|
|`__cpp_lib_saturation_arithmetic`|`202603L`|[`<numeric>`](/reference/numeric.md)に飽和演算 (Saturation Arithmetic) として[`std::saturating_add()`](/reference/numeric/saturating_add.md)などの関数を追加|[`<numeric>`](/reference/numeric.md)|
|`__cpp_lib_senders`|`202506L`||[`<execution>`](/reference/execution.md)|
|`__cpp_lib_simd`|`202506L`|データ並列ライブラリとして、[`<simd>`](/reference/simd.md.nolink)を追加|[`<simd>`](/reference/simd.md.nolink)|
|`__cpp_lib_simd_complex`|`202502L`|[`<simd>`](/reference/simd.md.nolink)が[`std::complex`](/reference/complex/complex.md)をサポートする|[`<simd>`](/reference/simd.md.nolink)|
|`__cpp_lib_simd_permutations`|`202506L`|[`<simd>`](/reference/simd.md.nolink)に`permute()`などを追加する|[`<simd>`](/reference/simd.md.nolink)|
|`__cpp_lib_simd`|`202506L`|データ並列ライブラリとして、[`<simd>`](/reference/simd.md)を追加|[`<simd>`](/reference/simd.md)|
|`__cpp_lib_simd_complex`|`202502L`|[`<simd>`](/reference/simd.md)が[`std::complex`](/reference/complex/complex.md)をサポートする|[`<simd>`](/reference/simd.md)|
|`__cpp_lib_simd_permutations`|`202506L`|[`<simd>`](/reference/simd.md)に`permute()`などを追加する|[`<simd>`](/reference/simd.md)|
|`__cpp_lib_smart_ptr_owner_equality`|`202306L`|[`<memory>`](/reference/memory.md)に[`std::owner_hash`](/reference/memory/owner_hash.md)と[`std::owner_equal`](/reference/memory/owner_equal.md)を追加|[`<memory>`](/reference/memory.md)|
|`__cpp_lib_span`|`202311L`|[`std::mdspan`](/reference/mdspan/mdspan.md)に[`at()`](/reference/mdspan/mdspan/at.md)メンバ関数を追加|[`<span>`](/reference/span.md)|
|`__cpp_lib_span_initializer_list`|`202311L`|[`std::span`](/reference/span/span.md)に[`std::initializer_list`](/reference/initializer_list/initializer_list.md)をとるコンストラクタを追加|[`<span>`](/reference/span.md)|
Expand Down
3 changes: 2 additions & 1 deletion reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
| [`<bit>`](/reference/bit.md) | ビット操作 | C++20 |
| [`<random>`](/reference/random.md) | 乱数生成 | C++11 |
| [`<valarray>`](/reference/valarray.md) | 数値の配列 | |
| [`<simd>`](/reference/simd.md) | データ並列型 | C++26 |
| [`<numeric>`](/reference/numeric.md) | 一般的な数値操作 | |
| [`<numbers>`](/reference/numbers.md) | 数値 | C++20 |
| [`<linalg>`](/reference/linalg.md) | 線形代数 | C++26 |
Expand Down Expand Up @@ -213,7 +214,7 @@
| [`<future>`](/reference/future.md) | Future | C++11 |
| [`<rcu>`](/reference/rcu.md) | データの参照・更新 | C++26 |
| [`<hazard_pointer>`](/reference/hazard_pointer.md.nolink) | ハザードポインタ | C++26 |
| [`<simd>`](/reference/simd.md.nolink) | データ並列 | C++26 |
| [`<simd>`](/reference/simd.md) | データ並列 | C++26 |


## <a id="clib-facilities" href="#clib-facilities">C言語互換ライブラリ</a>
Expand Down
18 changes: 18 additions & 0 deletions reference/bit.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@
| [`rotr`](bit/rotr.md) | 右循環ビットシフト (function template) | C++20 |


## ビットシフト

| 名前 | 説明 | 対応バージョン |
|------|------|----------------|
| [`shl`](bit/shl.md) | 左ビットシフト(未定義動作にならない) (function template) | C++29 |
| [`shr`](bit/shr.md) | 右ビットシフト(未定義動作にならない) (function template) | C++29 |


## ビット並べ替え

| 名前 | 説明 | 対応バージョン |
|------|------|----------------|
| [`bit_reverse`](bit/bit_reverse.md) | ビット列の並びを反転する (function template) | C++29 |
| [`bit_repeat`](bit/bit_repeat.md) | 最下位`l`ビットのパターンを繰り返す (function template) | C++29 |
| [`bit_compress`](bit/bit_compress.md) | マスクで立っている位置のビットを下位へ詰める (function template) | C++29 |
| [`bit_expand`](bit/bit_expand.md) | 下位ビットをマスクで立っている位置へ展開する (function template) | C++29 |


## ビットカウント

| 名前 | 説明 | 対応バージョン |
Expand Down
78 changes: 78 additions & 0 deletions reference/bit/bit_compress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# bit_compress
* bit[meta header]
* std[meta namespace]
* function template[meta id-type]
* cpp29[meta cpp]

```cpp
namespace std {
template <class T>
constexpr T bit_compress(T x, T m) noexcept; // C++29
}
```

## 概要
マスク`m`でビットが立っている位置の`x`のビットを集め、結果の下位ビットへ詰めて配置する(parallel bits extract)。

x86の`PEXT`命令に相当する操作である。


## テンプレートパラメータ制約
- 型`T`が符号なし整数型であること


## 戻り値
`T`のビット数を`N`とする。`m`の第`n`ビットが`1`である位置を下位から順に走査し、対応する`x`の第`n`ビットを結果の下位側から順に詰めた値を返す。すなわち、結果の第`k`ビットは、`m`のなかで`k`番目に立っているビット位置の`x`のビットに等しい。


## 例外
投げない


## 備考
- [`bit_expand`](bit_expand.md)は逆操作である。`m`のビットがすべて`1`のとき、`bit_expand(bit_compress(x, m), m)`は`x`に等しい。


## 例
```cpp example
#include <bit>
#include <cstdint>
#include <print>

int main()
{
std::uint8_t x = 0b1011'0100;
std::uint8_t m = 0b1111'0000; // 上位4ビットを抽出

std::uint8_t r = std::bit_compress(x, m);

std::println("{:08b}", r);
}
```
* std::bit_compress[color ff0000]

### 出力
```
00001011
```


## バージョン
### 言語
- C++29

### 処理系
- [Clang](/implementation.md#clang): 22 [mark noimpl]
- [GCC](/implementation.md#gcc): 16.1 [mark noimpl]
- [Visual C++](/implementation.md#visual_cpp): 2026 Update 2 [mark noimpl]


## 関連項目
- [`std::bit_expand`](bit_expand.md)
- [`std::bit_reverse`](bit_reverse.md)
- [`std::bit_repeat`](bit_repeat.md)


## 参照
- [P3104R3 Bit permutations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3104r3.html)
- C++29で追加された
78 changes: 78 additions & 0 deletions reference/bit/bit_expand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# bit_expand
* bit[meta header]
* std[meta namespace]
* function template[meta id-type]
* cpp29[meta cpp]

```cpp
namespace std {
template <class T>
constexpr T bit_expand(T x, T m) noexcept; // C++29
}
```

## 概要
`x`の下位ビットを、マスク`m`でビットが立っている位置へ順に配置する(parallel bits deposit)。

x86の`PDEP`命令に相当する操作であり、[`bit_compress`](bit_compress.md)の逆操作である。


## テンプレートパラメータ制約
- 型`T`が符号なし整数型であること


## 戻り値
`T`のビット数を`N`とする。`m`の第`n`ビットが`1`である位置を下位から順に走査し、`x`の下位ビットから順に取り出した値をその位置へ配置した値を返す。すなわち、`m`のなかで`k`番目に立っているビット位置には、`x`の第`k`ビットが配置される。


## 例外
投げない


## 備考
- [`bit_compress`](bit_compress.md)は逆操作である。`m`のビットがすべて`1`のとき、`bit_expand(bit_compress(x, m), m)`は`x`に等しい。


## 例
```cpp example
#include <bit>
#include <cstdint>
#include <print>

int main()
{
std::uint8_t x = 0b0000'1011;
std::uint8_t m = 0b1111'0000; // 下位4ビットを上位4ビットの位置へ展開

std::uint8_t r = std::bit_expand(x, m);

std::println("{:08b}", r);
}
```
* std::bit_expand[color ff0000]

### 出力
```
10110000
```


## バージョン
### 言語
- C++29

### 処理系
- [Clang](/implementation.md#clang): 22 [mark noimpl]
- [GCC](/implementation.md#gcc): 16.1 [mark noimpl]
- [Visual C++](/implementation.md#visual_cpp): 2026 Update 2 [mark noimpl]


## 関連項目
- [`std::bit_compress`](bit_compress.md)
- [`std::bit_reverse`](bit_reverse.md)
- [`std::bit_repeat`](bit_repeat.md)


## 参照
- [P3104R3 Bit permutations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3104r3.html)
- C++29で追加された
78 changes: 78 additions & 0 deletions reference/bit/bit_repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# bit_repeat
* bit[meta header]
* std[meta namespace]
* function template[meta id-type]
* cpp29[meta cpp]

```cpp
namespace std {
template <class T>
constexpr T bit_repeat(T x, int l); // C++29
}
```

## 概要
値`x`の最下位`l`ビットのパターンを、`T`の幅いっぱいに繰り返した値を求める。


## テンプレートパラメータ制約
- 型`T`が符号なし整数型であること


## 事前条件
- `l`が`0`より大きいこと


## 戻り値
`T`のビット数を`N`([`std::numeric_limits`](/reference/limits/numeric_limits.md)`<T>::digits`)とする。第`n`ビット(`0`以上`N`未満)が`x`の第`n % l`ビットに等しい値を返す。


## 例外
投げない


## 備考
- 事前条件に違反する関数呼び出し式は、定数式として評価されない。


## 例
```cpp example
#include <bit>
#include <cstdint>
#include <print>

int main()
{
// 最下位4ビットのパターン 0b1100 を繰り返す
std::uint32_t r = std::bit_repeat(std::uint32_t{0xc}, 4);

std::println("{:08x}", r);
}
```
* std::bit_repeat[color ff0000]

### 出力
```
cccccccc
```


## バージョン
### 言語
- C++29

### 処理系
- [Clang](/implementation.md#clang): 22 [mark noimpl]
- [GCC](/implementation.md#gcc): 16.1 [mark noimpl]
- [Visual C++](/implementation.md#visual_cpp): 2026 Update 2 [mark noimpl]


## 関連項目
- [`std::bit_reverse`](bit_reverse.md)
- [`std::bit_compress`](bit_compress.md)
- [`std::bit_expand`](bit_expand.md)


## 参照
- [P3104R3 Bit permutations](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3104r3.html)
- C++29で追加された
Loading
Loading