Skip to content

Commit

Permalink
C++26 P2734R0対応
Browse files Browse the repository at this point in the history
  • Loading branch information
yohhoy committed Sep 26, 2023
1 parent 46f89bc commit 38b9677
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 44 deletions.
6 changes: 5 additions & 1 deletion reference/ratio.md
Expand Up @@ -38,6 +38,8 @@

| 名前 | 説明 | 対応バージョン |
|---------------------------------|-------------------|----------------|
| [`quecto`](ratio/si_prefix.md) | クエクト(type-alias) | C++26 |
| [`ronto`](ratio/si_prefix.md) | ロント(type-alias) | C++26 |
| [`yocto`](ratio/si_prefix.md) | ヨクト(type-alias) | C++11 |
| [`zepto`](ratio/si_prefix.md) | ゼプト(type-alias) | C++11 |
| [`atto`](ratio/si_prefix.md) | アト(type-alias) | C++11 |
Expand All @@ -58,6 +60,8 @@
| [`exa`](ratio/si_prefix.md) | エクサ(type-alias) | C++11 |
| [`zetta`](ratio/si_prefix.md) | ゼタ(type-alias) | C++11 |
| [`yotta`](ratio/si_prefix.md) | ヨタ(type-alias) | C++11 |
| [`ronna`](ratio/si_prefix.md) | ロナ(type-alias) | C++26 |
| [`quetta`](ratio/si_prefix.md) | クエタ(type-alias) | C++26 |


## バージョン
Expand All @@ -67,4 +71,4 @@

## 参照
- [N2661 A Foundation to Sleep On](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm)

- [P2734R0 Adding the new SI prefixes](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2734r0.pdf)
99 changes: 56 additions & 43 deletions reference/ratio/si_prefix.md
Expand Up @@ -6,59 +6,67 @@

```cpp
namespace std {
using yocto = ratio<1, 1000000000000000000000000>;
using zepto = ratio<1, 1000000000000000000000>;
using atto = ratio<1, 1000000000000000000>;
using femto = ratio<1, 1000000000000000>;
using pico = ratio<1, 1000000000000>;
using nano = ratio<1, 1000000000>;
using micro = ratio<1, 1000000>;
using milli = ratio<1, 1000>;
using centi = ratio<1, 100>;
using deci = ratio<1, 10>;
using deca = ratio< 10, 1>;
using hecto = ratio< 100, 1>;
using kilo = ratio< 1000, 1>;
using mega = ratio< 1000000, 1>;
using giga = ratio< 1000000000, 1>;
using tera = ratio< 1000000000000, 1>;
using peta = ratio< 1000000000000000, 1>;
using exa = ratio< 1000000000000000000, 1>;
using zetta = ratio< 1000000000000000000000, 1>;
using yotta = ratio<1000000000000000000000000, 1>;
using quecto = ratio<1, 1000000000000000000000000000000>; // C++26
using ronto = ratio<1, 1000000000000000000000000000>; // C++26
using yocto = ratio<1, 1000000000000000000000000>;
using zepto = ratio<1, 1000000000000000000000>;
using atto = ratio<1, 1000000000000000000>;
using femto = ratio<1, 1000000000000000>;
using pico = ratio<1, 1000000000000>;
using nano = ratio<1, 1000000000>;
using micro = ratio<1, 1000000>;
using milli = ratio<1, 1000>;
using centi = ratio<1, 100>;
using deci = ratio<1, 10>;
using deca = ratio< 10, 1>;
using hecto = ratio< 100, 1>;
using kilo = ratio< 1000, 1>;
using mega = ratio< 1000000, 1>;
using giga = ratio< 1000000000, 1>;
using tera = ratio< 1000000000000, 1>;
using peta = ratio< 1000000000000000, 1>;
using exa = ratio< 1000000000000000000, 1>;
using zetta = ratio< 1000000000000000000000, 1>;
using yotta = ratio< 1000000000000000000000000, 1>;
using ronna = ratio< 1000000000000000000000000000, 1>; // C++26
using quetta = ratio<1000000000000000000000000000000, 1>; // C++26
}
```
* ratio[link ratio.md]
## 概要
これらは、コンパイル時有理数である[`ratio`](ratio.md)を利用した、SI単位系(The International System of Units : 国際単位系)の接頭辞を表す型である。
| 型 | 説明 |
|---------|----------|
| `yocto` | ヨクト |
| `zepto` | ゼプト |
| `atto` | アト |
| `femto` | フェムト |
| `pico` | ピコ |
| `nano` | ナノ |
| `micro` | マイクロ |
| `milli` | ミリ |
| `centi` | センチ |
| `deci` | デシ |
| `deca` | デカ |
| `hecto` | ヘクト |
| `kilo` | キロ |
| `mega` | メガ |
| `giga` | ギガ |
| `tera` | テラ |
| `peta` | ペタ |
| `exa` | エクサ |
| `zetta` | ゼタ |
| `yotta` | ヨタ |
| 型 | 説明 | 10の冪 |
|---------|----------|------|
| `quecto` | クエクト | -30 |
| `ronto` | ロント | -27 |
| `yocto` | ヨクト | -24 |
| `zepto` | ゼプト | -21 |
| `atto` | アト | -18 |
| `femto` | フェムト | -15 |
| `pico` | ピコ | -12 |
| `nano` | ナノ | - 9 |
| `micro` | マイクロ | -6 |
| `milli` | ミリ | -3 |
| `centi` | センチ | -2 |
| `deci` | デシ | -1 |
| `deca` | デカ | 1 |
| `hecto` | ヘクト | 2 |
| `kilo` | キロ | 3 |
| `mega` | メガ | 6 |
| `giga` | ギガ | 9 |
| `tera` | テラ | 12 |
| `peta` | ペタ | 15 |
| `exa` | エクサ | 18 |
| `zetta` | ゼタ | 21 |
| `yotta` | ヨタ | 24 |
| `ronna` | ロナ | 27 |
| `quetta` | クエタ | 30 |
## 備考
`yocto`、`zepto`、`zetta`、`yotta`は、[`intmax_t`](/reference/cstdint/intmax_t.md)型で値を表現できる場合のみ定義され、表現できない場合は定義されない。
`quecto`, `ronto`, `yocto`、`zepto`、`zetta`、`yotta`, `ronna`, `quetta`は、[`intmax_t`](/reference/cstdint/intmax_t.md)型で値を表現できる場合のみ定義され、表現できない場合は定義されない。
## 例
Expand Down Expand Up @@ -109,4 +117,9 @@ int main()
- [GCC](/implementation.md#gcc): 4.4.7
- [Visual C++](/implementation.md#visual_cpp): ??

### 備考
`std::intmax_t`型が64bit幅の処理系では、SI接頭辞`quecto``zepto``zetta``quetta`を表現できないため、これらの型別名は定義されない。


## 参照
- [P2734R0 Adding the new SI prefixes](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2734r0.pdf)

0 comments on commit 38b9677

Please sign in to comment.