Skip to content

Commit c0baa18

Browse files
committed
Replace CPP2_TYPEOF to get full type of x
CPP2_TYPEOF revoves cv-qualifiers which matters to matching overloads
1 parent 262b86f commit c0baa18

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/cpp2util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,13 +1789,13 @@ inline constexpr auto as_( auto&& x ) -> decltype(auto)
17891789
{
17901790
if constexpr (narrowing<C, CPP2_TYPEOF(x)>) {
17911791
static_assert(
1792-
program_violates_type_safety_guarantee<C, CPP2_TYPEOF(x)>,
1792+
program_violates_type_safety_guarantee<C, decltype(x)>,
17931793
"'as' does not allow unsafe narrowing conversions - if you're sure you want this, use `unsafe_narrow<T>()` to force the conversion"
17941794
);
17951795
}
17961796
else if constexpr( requires{ { as<C>(CPP2_FORWARD(x)) } -> std::same_as<nonesuch_>; } ) {
17971797
static_assert(
1798-
program_violates_type_safety_guarantee<C, CPP2_TYPEOF(x)>,
1798+
program_violates_type_safety_guarantee<C, decltype(x)>,
17991799
"No safe 'as' cast available - please check your cast"
18001800
);
18011801
}
@@ -1808,13 +1808,13 @@ inline constexpr auto as_() -> decltype(auto)
18081808
{
18091809
if constexpr ( !requires { as<C, x>(); }) {
18101810
static_assert(
1811-
program_violates_type_safety_guarantee<C, CPP2_TYPEOF(x)>,
1811+
program_violates_type_safety_guarantee<C, decltype(x)>,
18121812
"No safe 'as' cast available - please check your cast"
18131813
);
18141814
}
18151815
if constexpr( requires { {as<C, x>()} -> std::same_as<nonesuch_>; } ) {
18161816
static_assert(
1817-
program_violates_type_safety_guarantee<C, CPP2_TYPEOF(x)>,
1817+
program_violates_type_safety_guarantee<C, decltype(x)>,
18181818
"Literal cannot be narrowed using 'as' - if you're sure you want this, use 'unsafe_narrow<T>()' to force the conversion"
18191819
);
18201820
}

0 commit comments

Comments
 (0)