mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:27:46 +00:00
LibGUI: Add GUI::Widget::try_set_layout<T>(...)
This is a fallible variant of set_layout<T>(...) that returns ErrorOr.
This commit is contained in:
parent
bc79be362d
commit
6b79745aa4
1 changed files with 8 additions and 0 deletions
|
@ -61,6 +61,14 @@ public:
|
|||
const Layout* layout() const { return m_layout.ptr(); }
|
||||
void set_layout(NonnullRefPtr<Layout>);
|
||||
|
||||
template<class T, class... Args>
|
||||
ErrorOr<NonnullRefPtr<T>> try_set_layout(Args&&... args)
|
||||
{
|
||||
auto layout = TRY(T::try_create(forward<Args>(args)...));
|
||||
set_layout(*layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
inline T& set_layout(Args&&... args)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue