Skip to content

Commit a057384

Browse files
committed
Use lifetimebound in Choice API
1 parent f97b528 commit a057384

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

subspace/choice/choice.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
352352
/// passed as the template parameter.
353353
template <TagsType V>
354354
requires(__private::ValueIsNotVoid<StorageTypeOfTag<V>>)
355-
constexpr inline decltype(auto) as() const& noexcept {
355+
constexpr inline decltype(auto) as() const& noexcept sus_lifetimebound {
356356
::sus::check(index_ == index<V>);
357357
return __private::find_choice_storage<index<V>>(storage_).as();
358358
}
@@ -376,7 +376,7 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
376376
/// passed as the template parameter.
377377
template <TagsType V>
378378
requires(__private::ValueIsNotVoid<StorageTypeOfTag<V>>)
379-
constexpr inline decltype(auto) as_mut() & noexcept {
379+
constexpr inline decltype(auto) as_mut() & noexcept sus_lifetimebound {
380380
::sus::check(index_ == index<V>);
381381
return __private::find_choice_storage_mut<index<V>>(storage_).as_mut();
382382
}
@@ -411,7 +411,8 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
411411
/// active member.
412412
template <TagsType V>
413413
requires(__private::ValueIsNotVoid<StorageTypeOfTag<V>>)
414-
constexpr inline Option<AccessTypeOfTagConst<V>> get() const& noexcept {
414+
constexpr inline Option<AccessTypeOfTagConst<V>> get() const& noexcept
415+
sus_lifetimebound {
415416
if (index_ != index<V>) return ::sus::none();
416417
return ::sus::some(__private::find_choice_storage<index<V>>(storage_).as());
417418
}
@@ -431,7 +432,8 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
431432
/// active member.
432433
template <TagsType V>
433434
requires(__private::ValueIsNotVoid<StorageTypeOfTag<V>>)
434-
constexpr inline Option<AccessTypeOfTagMut<V>> get_mut() & noexcept {
435+
constexpr inline Option<AccessTypeOfTagMut<V>> get_mut() & noexcept
436+
sus_lifetimebound {
435437
if (index_ != index<V>) return ::sus::none();
436438
return ::sus::some(
437439
__private::find_choice_storage_mut<index<V>>(storage_).as_mut());
@@ -467,7 +469,7 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
467469
template <TagsType V>
468470
requires(__private::ValueIsNotVoid<StorageTypeOfTag<V>>)
469471
constexpr inline decltype(auto) get_unchecked(
470-
::sus::marker::UnsafeFnMarker) const& noexcept {
472+
::sus::marker::UnsafeFnMarker) const& noexcept sus_lifetimebound {
471473
return __private::find_choice_storage<index<V>>(storage_).as();
472474
}
473475
// If the storage is a value type, it can't be accessed by reference in an
@@ -492,7 +494,7 @@ class Choice<__private::TypeList<Ts...>, Tags...> final {
492494
template <TagsType V>
493495
requires(__private::ValueIsNotVoid<StorageTypeOfTag<V>>)
494496
constexpr inline decltype(auto) get_unchecked_mut(
495-
::sus::marker::UnsafeFnMarker) & noexcept {
497+
::sus::marker::UnsafeFnMarker) & noexcept sus_lifetimebound {
496498
return __private::find_choice_storage_mut<index<V>>(storage_).as_mut();
497499
}
498500

0 commit comments

Comments
 (0)