Added ability to provide not_null to CreateChild function.
This commit is contained in:
parent
69e474ea77
commit
6d1014fa8f
1 changed files with 12 additions and 7 deletions
|
|
@ -56,8 +56,9 @@ inline base::unique_qptr<Widget> CreateObject(Args &&...args) {
|
|||
|
||||
template <typename Value, typename Parent, typename ...Args>
|
||||
inline Value *CreateChild(
|
||||
Parent *parent,
|
||||
Parent parent,
|
||||
Args &&...args) {
|
||||
if constexpr (std::is_pointer_v<Parent>) {
|
||||
Expects(parent != nullptr);
|
||||
|
||||
if constexpr (std::is_base_of_v<QObject, Value>) {
|
||||
|
|
@ -67,6 +68,10 @@ inline Value *CreateChild(
|
|||
parent,
|
||||
std::forward<Args>(args)...)->value();
|
||||
}
|
||||
} else {
|
||||
static_assert(requires(const Parent &t) { t.get(); });
|
||||
return new Value(parent.get(), std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue