考虑:
class test {
private:
int n;
int impl () const noexcept {
return n;
}
public:
test () = delete;
test (int n) noexcept : n(n) { }
int get () const noexcept(noexcept(impl())) {
return impl();
}
};
海湾合作委员会说不:
test.cpp:27:43: error: cannot call member function 'int test::impl() const' with
out object
int get () const noexcept(noexcept(impl())) {
相似地:
test.cpp:27:38: error: invalid use of 'this' at top level
int get () const noexcept(noexcept(this->impl())) {
和
test.cpp:31:58: error: invalid use of incomplete type 'class test'
int get () const noexcept(noexcept(std::declval<test>().impl())) {
^
test.cpp:8:7: error: forward declaration of 'class test'
class test {
这是符合标准的预期行为,还是 GCC (4.8.0) 中的错误?