mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
parent
b9bdd01532
commit
f07f9fcd70
3 changed files with 253 additions and 93 deletions
|
|
@ -17,6 +17,43 @@ namespace private_api {
|
|||
using ItemTreeRc = vtable::VRc<cbindgen_private::ItemTreeVTable>;
|
||||
using slint::LogicalPosition;
|
||||
|
||||
/// Looking forward for C++23 std::optional::transform
|
||||
template<typename T, typename F>
|
||||
auto optional_transform(const std::optional<T> &o, F &&f) -> decltype(std::optional(f(*o)))
|
||||
{
|
||||
if (o) {
|
||||
return std::optional(f(*o));
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<typename T, typename F>
|
||||
void optional_then(const std::optional<T> &o, F &&f)
|
||||
{
|
||||
if (o) {
|
||||
f(*o);
|
||||
}
|
||||
}
|
||||
|
||||
/// Waiting for C++23 std::optional::and_then
|
||||
template<typename T, typename F>
|
||||
auto optional_and_then(const std::optional<T> &o, F &&f) -> decltype(f(*o))
|
||||
{
|
||||
if (o) {
|
||||
return f(*o);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T optional_or_default(const std::optional<T> &o)
|
||||
{
|
||||
if (o) {
|
||||
return *o;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
class WindowAdapterRc
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue