aui
aui copied to clipboard
Implicit capture of 'this' with a capture default of '=' is deprecated
AUI and AUI-based code relies of implicit capture of this pointer which might lead to memory-related issues. Because of this behaviour, I can't do:
template<typename T>
struct ListView {
contract::In<AVector<T>> items;
contract::In<std::size_t> selectionId;
contract::Slot<std::size_t> onSelectionChange;
std::function<_<AView>(_<AView>)> body = ListViewDefaults::defaultBody;
std::function<_<AView>(_<AView>)> scrollArea = ListViewDefaults::defaultScrollArea;
_<AView> operator()() {
return body(scrollArea(AUI_DECLARATIVE_FOR(i, items.value(), AVerticalLayout) { // <-- implcit capture of 'this'
return Label { "{}"_format(i) };
}));
}
};
The code above emits a warning and crashes.
When building AUI on any compiler, it spams with this warning. I suggest rethinking the code that relies on reasonably deprecated implicit capture of 'this' and leverage this warning to error.