Movatterモバイル変換


[0]ホーム

URL:



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

119. Should virtual functions be allowed to strengthen the exception specification?

Section: 16.4.6.14[res.on.exception.handling]Status:TC1Submitter: Judy WardOpened: 1998-12-15Last modified: 2016-01-28

Priority:Not Prioritized

View otheractive issues in [res.on.exception.handling].

View all otherissues in [res.on.exception.handling].

View all issues withTC1 status.

Discussion:

Section 16.4.6.14[res.on.exception.handling] states:

"An implementation may strengthen the exception-specificationfor a function by removing listed exceptions."

The problem is that if an implementation is allowed to do this forvirtual functions, then a library user cannot write a class thatportably derives from that class.

For example, this would not compile if ios_base::failure::~failurehad an empty exception specification:

#include <ios>#include <string>class D : public std::ios_base::failure {public:        D(const std::string&);        ~D(); // error - exception specification must be compatible with               // overridden virtual function ios_base::failure::~failure()};

Proposed resolution:

Change Section 16.4.6.14[res.on.exception.handling] from:

     "may strengthen theexception-specification for a function"

to:

     "may strengthen theexception-specification for a non-virtual function".


[8]ページ先頭

©2009-2026 Movatter.jp