Skip to content

Commit 3fb4d2f

Browse files
committed
Add as(strict) casts
1 parent bc800ad commit 3fb4d2f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/cpp2util.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,19 @@ auto as(T&& t) -> auto
683683
return cpp2::optional_as<C>(std::forward<T>(t));
684684
}
685685

686+
template< typename T >
687+
struct strict {
688+
using type = T;
689+
};
690+
691+
template< typename S, typename T >
692+
auto as(T&& t) -> auto
693+
requires (is<cpp2::strict>(S{}))
694+
{
695+
using C = typename S::type;
696+
return cpp2::strict_as<C>(std::forward<T>(t));
697+
}
698+
686699
//-------------------------------------------------------------------------------------------------------------
687700
// std::variant is and as
688701
//

0 commit comments

Comments
 (0)