2009-01-28

N2530について

このN2530自体、だいぶ古い。しかし、どうやらこれが最新版のようだ。現行ドラフトに取り入れられているものとは、だいぶ変わっている。

内容としては簡単なもので、type_infoを連想コンテナに入れられるようにしましょうというものだ。具体的には、unordered containerへの対応と、type_infoのラッパクラスであるtype_indexの定義である。

type_infoのメンバ関数、hash_code()の戻り値については、N2530では、以下の通りになっている。

an unspecified value, except that within a single execution of the program, two type_info which compare equal should return equal values.

具体的な値は規定されない。ただし、プログラムのある実行中において、同等と比較される二つのtype_infoは、同じ値を返した方が良い。

これはもちろんありえない。同等と比較されるのであれば、同じ戻り値を返すことが保障されていなければ、意味がない。現行ドラフトでは、以下のようになっている。

an unspecified value, except that within a single execution of the program, it shall return the same value for any two type_info objects which compare equal.

具体的な値は規定されない。ただし、プログラムのある実行中において、あらゆる二つの同等と比較されるtype_infoのオブジェクトは、同じ値を返さねばならない。

現行ドラフトでは、本来の意図通りのshallとなっている。また、細かい言い回しが変更されている。とくに、type_infoのオブジェクトとなっているのが、分かりやすいと思う。

ところで、ひとつ問題がある。それは、hash<type_index>に関するものだ。18.6.2.2で、規定しているのだが、N2530にある、特殊化の宣言部分は、現行ドラフトに入っていない。そして、もうひとつ重大な問題がある。hash関数自身の文章だ。hash関数は、20.6.17で規定されているのだが、以下のようになっている。

This class template is only required to be instantiable for integer types (3.9.1), floatingpoint types (3.9.1), pointer types (8.3.1), and std::string, std::u16string, std::u32string, std ::wstring, std::error_code, std::thread::id, std::bitset, and std::vector<bool>.

std::type_indexに言及していないが、いいのだろうか。

No comments:

Post a Comment

You can use some HTML elements, such as <b>, <i>, <a>, also, some characters need to be entity referenced such as <, > and & Your comment may need to be confirmed by blog author. Your comment will be published under GFDL 1.3 or later license with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.