diff options
| author | mTvare <mTvare6@proton.me> | 2025-01-11 02:44:43 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 13:14:43 -0800 |
| commit | f199640bb31e1e273e34a068ea0fb7a55f2afb5e (patch) | |
| tree | ce9c6e276a6bee7b5390f0596469e2793e61eb20 /source | |
| parent | 803e0c9f9a9dc4b01e29ebbf3b37a5bba782ac83 (diff) | |
Add overload for select to handle Optional<T> (#6022)
Fixes #6020
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/core.meta.slang | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index ba8decc12..5c30da1e7 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -729,6 +729,18 @@ __generic<T, let N : int> __intrinsic_op(select) vector<T,N> operator?:(vector<b __generic<T> __intrinsic_op(select) T select(bool condition, T ifTrue, T ifFalse); __generic<T, let N : int> __intrinsic_op(select) vector<T,N> select(vector<bool,N> condition, vector<T,N> ifTrue, vector<T,N> ifFalse); +[ForceInline] +__generic<T> Optional<T> select(bool condition, __none_t ifTrue, T ifFalse) +{ + return select(condition, Optional<T>(none), Optional<T>(ifFalse)); +} + +[ForceInline] +__generic<T> Optional<T> select(bool condition, T ifTrue, __none_t ifFalse) +{ + return select(condition, Optional<T>(ifTrue), Optional<T>(none)); +} + // Allow real-number types to be cast into each other //@hidden: __intrinsic_op($(kIROp_FloatCast)) |
