yohhoyの日記

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

名無しの変数

プログラミング言語C++には、言語仕様の定義上 “名前のない変数(variable)” が存在する。誰得情報。

try {
} catch (std::exception&) {  // ★
}

C++14 3/p6より引用(下線部は強調)。C++17では6/p6。

A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable's name, if any, denotes the reference or object.

同Wordingを導入したCWG DR 1769より一部引用。

Additional discussion has pointed out that, although the unnamed handler parameter is no longer called a "temporary" in the proposed resolution, 15.2 [class.temporary] paragraph 1 still lists "entering a handler (18.3 [except.handle])" as one of the contexts in which a temporary is created. A question was also raised as to whether it is necessary to deal with named and unnamed handler parameters separately, since both are now referred to as "variables" in the revised wording. This issue has therefore been returned to "review" status to allow consideration of these points.

関連URL