id err = @(s); // expected-error{{illegal type 'SomeStruct' (aka '_SomeStruct') used in a boxed expression}}
NonTriviallyCopyable ntc;
id ntcErr = @(ntc); // expected-error{{non-trivially copyable type 'NonTriviallyCopyable' cannot be used in a boxed expression}}
}
CGRect getRect() {
CGRect r;
return r;
}
SomeStruct getSomeStruct() {
SomeStruct s;
return s;
}
void rvalue() {
id rv_rect = @(getRect());
id rv_some_struct = @(getSomeStruct()); // expected-error {{illegal type 'SomeStruct' (aka '_SomeStruct') used in a boxed expression}}
}
template <class T> id box(T value) { return @(value); } // expected-error{{non-trivially copyable type 'NonTriviallyCopyable' cannot be used in a boxed expression}}
id y = box(ntc); // expected-note{{in instantiation of function template specialization 'box<NonTriviallyCopyable>' requested here}}
}
template <unsigned i> id boxRect(NSRect rect) { return @(rect); }
template <unsigned i> id boxNTC(NonTriviallyCopyable ntc) { return @(ntc); } // expected-error{{non-trivially copyable type 'NonTriviallyCopyable' cannot be used in a boxed expression}}