Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++14 status.

2144. Missingnoexcept specification intype_index

Section: 17.7.7[type.index]Status:C++14Submitter: Daniel KrüglerOpened: 2012-03-18Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [type.index].

View all issues withC++14 status.

Discussion:

The class typetype_index is a thin wrapper oftype_info toadapt it as a valid associative container element. Similar totype_info, all member functions have an effectivenoexcept(true) specification, with the exception ofhash_code() andname(). The actual effects of thesefunctions is a direct call totype_info'shash_code() andname function, but according to 17.7[support.rtti] these are bothnoexceptfunctions, so there is no reason for not declaring them asnoexcept, too. In fact,one of the suggested changes of the original proposing paperN2530specifically was to ensure thattype_info would get ahash_code()function that guarantees not to throw exceptions (during that time thehashrequirements did not allow to exit with an exception). From this we can conclude thattype_index::hash_code() was intended to be nothrow.

It seems both consistent and technically simply to require these functions to benoexcept.

[2013-03-15 Issues Teleconference]

Moved to Tentatively Ready.

[2013-04-20 Bristol]

Proposed resolution:

This wording is relative to N3376.

  1. Modify the classtype_index synopsis, [type.index.overview] as indicated:

    namespace std {  class type_index {  public:    type_index(const type_info& rhs) noexcept;    bool operator==(const type_index& rhs) const noexcept;    bool operator!=(const type_index& rhs) const noexcept;    bool operator< (const type_index& rhs) const noexcept;    bool operator<= (const type_index& rhs) const noexcept;    bool operator> (const type_index& rhs) const noexcept;    bool operator>= (const type_index& rhs) const noexcept;    size_t hash_code() constnoexcept;    const char* name() constnoexcept;  private:    const type_info* target;// exposition only// Note that the use of a pointer here, rather than a reference,// means that the default copy/move constructor and assignment// operators will be provided and work as expected.  };}
  1. Modify the prototype definitions in [type.index.members] as indicated:

    size_t hash_code() constnoexcept;

    -8-Returns:target->hash_code()

    const char* name() constnoexcept;

    -9-Returns:target->name()


[8]ページ先頭

©2009-2026 Movatter.jp