検討:
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();
}
};
GCCはノーと言います:
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) のバグですか?