yohhoyの日記

技術的メモをしていきたい日記

ジュラシック・パーク in C++ Standard

プログラミング言語C++標準規格に潜む恐竜たち。🦕🦖

C++20(N4861) D.5 Deprecated volatile typesより引用。*1

1 Postfix ++ and -- expressions (7.6.1.5) and prefix ++ and -- expressions (7.6.2.2) of volatile-qualified arithmetic and pointer types are deprecated.

volatile int velociraptor;
++velociraptor;  // deprecated

2 Certain assignments where the left operand is a volatile-qualified non-class type are deprecated; see 7.6.19.

int neck, tail;
volatile int brachiosaur;
brachiosaur = neck;                // OK
tail = brachiosaur;                // OK
tail = brachiosaur = neck;         // deprecated
brachiosaur += neck;               // deprecated
brachiosaur = brachiosaur + neck;  // OK

3 A function type (9.3.3.5) with a parameter with volatile-qualified type or with a volatile-qualified return type is deprecated.

volatile struct amber jurassic();                             // deprecated
void trex(volatile short left_arm, volatile short right_arm); // deprecated
void fly(volatile struct pterosaur* pteranodon);              // OK

4 A structured binding (9.6) of a volatile-qualified type is deprecated.

struct linhenykus { short forelimb; };
void park(linhenykus alvarezsauroid) {
  volatile auto [what_is_this] = alvarezsauroid;  // deprecated
  // ...
}

メモ:

おまけ:

関連URL

*1:Annex D Compatibility features は normative のため、正式C++20仕様の一部とみなされる。