diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-04 19:07:55 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-04 21:04:06 +0100 |
commit | 028c011760b5b665fc2a72bb3c11fd3a6ca60d2c (patch) | |
tree | a961293992de78ebac5c3ffec864179d661dcc09 /Libraries/LibCore | |
parent | fb09b6a8cec02cc473b3fed326d99055d80a60ba (diff) | |
download | serenity-028c011760b5b665fc2a72bb3c11fd3a6ca60d2c.zip |
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can
simply vend a ChildType&. This allows us to use "." instead of "->"
at the call site, which is quite nice. :^)
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r-- | Libraries/LibCore/Object.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibCore/Object.h b/Libraries/LibCore/Object.h index d007818b0e..6f4a106a4f 100644 --- a/Libraries/LibCore/Object.h +++ b/Libraries/LibCore/Object.h @@ -121,11 +121,11 @@ public: } template<class T, class... Args> - inline NonnullRefPtr<T> add(Args&&... args) + inline T& add(Args&&... args) { - auto t = T::construct(forward<Args>(args)...); - add_child(*t); - return t; + auto child = T::construct(forward<Args>(args)...); + add_child(*child); + return child; } virtual bool is_visible_for_timer_purposes() const; |