Skip to content

Commit

Permalink
Change _Always_false to false for functions (#4591)
Browse files Browse the repository at this point in the history
Co-authored-by: Casey Carter <[email protected]>
  • Loading branch information
StephanTLavavej and CaseyCarter authored Apr 19, 2024
1 parent a58d716 commit 1955118
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 126 deletions.
12 changes: 6 additions & 6 deletions stl/inc/algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ __declspec(noalias) void _Reverse_copy_vectorized(const void* _First, const void
} else if constexpr (_Nx == 8) {
::__std_reverse_copy_trivially_copyable_8(_First, _Last, _Dest);
} else {
static_assert(_Always_false<integral_constant<size_t, _Nx>>, "Unexpected size");
static_assert(false, "Unexpected size");
}
}

Expand All @@ -116,7 +116,7 @@ pair<_Ty*, _Ty*> _Minmax_element_vectorized(_Ty* const _First, _Ty* const _Last)
} else if constexpr (sizeof(_Ty) == 8) {
_Res = ::__std_minmax_element_8(_First, _Last, _Signed);
} else {
static_assert(_Always_false<_Ty>, "Unexpected size");
static_assert(false, "Unexpected size");
}

return {const_cast<_Ty*>(static_cast<const _Ty*>(_Res._Min)), const_cast<_Ty*>(static_cast<const _Ty*>(_Res._Max))};
Expand Down Expand Up @@ -162,7 +162,7 @@ auto _Minmax_vectorized(_Ty* const _First, _Ty* const _Last) noexcept {
return ::__std_minmax_8u(_First, _Last);
}
} else {
static_assert(_Always_false<_Ty>, "Unexpected size");
static_assert(false, "Unexpected size");
}
}

Expand All @@ -189,7 +189,7 @@ _Ty* _Find_last_vectorized(_Ty* const _First, _Ty* const _Last, const _TVal _Val
return const_cast<_Ty*>(
static_cast<const _Ty*>(::__std_find_last_trivial_8(_First, _Last, static_cast<uint64_t>(_Val))));
} else {
static_assert(_Always_false<_Ty>, "Unexpected size");
static_assert(false, "Unexpected size");
}
}

Expand All @@ -203,7 +203,7 @@ _Ty1* _Find_first_of_vectorized(
return const_cast<_Ty1*>(
static_cast<const _Ty1*>(::__std_find_first_of_trivial_2(_First1, _Last1, _First2, _Last2)));
} else {
static_assert(_Always_false<_Ty1>, "Unexpected size");
static_assert(false, "Unexpected size");
}
}

Expand All @@ -221,7 +221,7 @@ __declspec(noalias) void _Replace_vectorized(
} else if constexpr (sizeof(_Ty) == 8) {
::__std_replace_8(_First, _Last, static_cast<uint64_t>(_Old_val), static_cast<uint64_t>(_New_val));
} else {
static_assert(_Always_false<_Ty>, "Unexpected size");
static_assert(false, "Unexpected size");
}
}

Expand Down
2 changes: 1 addition & 1 deletion stl/inc/bit
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ _NODISCARD constexpr _Ty byteswap(const _Ty _Val) noexcept {
} else if constexpr (sizeof(_Ty) == 8) {
return static_cast<_Ty>(_Byteswap_uint64(static_cast<unsigned long long>(_Val)));
} else {
static_assert(_Always_false<_Ty>, "Unexpected integer size");
static_assert(false, "Unexpected integer size");
}
}
#endif // _HAS_CXX23
Expand Down
11 changes: 5 additions & 6 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -3030,15 +3030,14 @@ namespace chrono {
clock_time_conversion<system_clock, utc_clock>{}(
clock_time_conversion<utc_clock, _SourceClock>{}(_Time)));
} else if constexpr (_Strat == _Clock_cast_strategy::_Two_step_ambiguous) {
static_assert(_Always_false<_Duration>,
static_assert(false,
"A two-step clock time conversion is required to be unique, "
"either through utc_clock or system_clock, but not both (N4950 [time.clock.cast.fn]/2).");
} else if constexpr (_Strat == _Clock_cast_strategy::_Three_step_ambiguous) {
static_assert(_Always_false<_Duration>,
"A three-step clock time conversion is required to be unique, "
"either utc-to-system or system-to-utc, but not both (N4950 [time.clock.cast.fn]/2).");
static_assert(false, "A three-step clock time conversion is required to be unique, "
"either utc-to-system or system-to-utc, but not both (N4950 [time.clock.cast.fn]/2).");
} else {
static_assert(_Always_false<_Duration>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}

Expand Down Expand Up @@ -5388,7 +5387,7 @@ namespace chrono {
} else if constexpr (_Is_specialization_v<_Ty, _Local_time_format_t>) {
return _Type == 'z' || _Type == 'Z' || _Is_valid_type<decltype(_Ty::_Time)>(_Type);
} else {
static_assert(_Always_false<_Ty>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}

Expand Down
12 changes: 6 additions & 6 deletions stl/inc/compare
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ namespace _Strong_order {
} else if constexpr (_Strat == _St::_Three) {
return static_cast<strong_ordering>(compare_three_way{}(_Left, _Right));
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}
};
Expand Down Expand Up @@ -579,7 +579,7 @@ namespace _Weak_order {
return static_cast<weak_ordering>(
static_cast<strong_ordering>(strong_order(_Left, _Right))); // intentional ADL
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}
};
Expand Down Expand Up @@ -664,7 +664,7 @@ namespace _Partial_order {
return static_cast<partial_ordering>(
static_cast<strong_ordering>(strong_order(_Left, _Right))); // intentional ADL
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}
};
Expand Down Expand Up @@ -720,7 +720,7 @@ namespace _Compare_strong_order_fallback {
: _Left < _Right ? strong_ordering::less
: strong_ordering::greater;
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}
};
Expand Down Expand Up @@ -770,7 +770,7 @@ namespace _Compare_weak_order_fallback {
: _Left < _Right ? weak_ordering::less
: weak_ordering::greater;
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}
};
Expand Down Expand Up @@ -829,7 +829,7 @@ namespace _Compare_partial_order_fallback {
: _Right < _Left ? partial_ordering::greater
: partial_ordering::unordered;
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
static_assert(false, "should be unreachable");
}
}
};
Expand Down
3 changes: 1 addition & 2 deletions stl/inc/experimental/generator
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ namespace experimental {

template <class _Uty>
_Uty&& await_transform(_Uty&& _Whatever) {
static_assert(_Always_false<_Uty>,
"co_await is not supported in coroutines of type std::experimental::generator");
static_assert(false, "co_await is not supported in coroutines of type std::experimental::generator");
return _STD forward<_Uty>(_Whatever);
}

Expand Down
10 changes: 4 additions & 6 deletions stl/inc/functional
Original file line number Diff line number Diff line change
Expand Up @@ -1621,12 +1621,10 @@ public:

template <class... _Signature>
class _Move_only_function_call {
static_assert((_Always_false<_Signature> || ...),
static_assert(_Always_false<integral_constant<size_t, sizeof...(_Signature)>>,
"std::move_only_function only accepts function types as template arguments, "
"with possibly const/ref/noexcept qualifiers.");

static_assert(sizeof...(_Signature) > 0,
"Unlike std::function, std::move_only_function does not define class template argument deduction guides.");
"with possibly const/ref/noexcept qualifiers. Also, unlike std::function, "
"std::move_only_function does not define class template argument deduction guides.");
};

// A script to generate the specializations is at
Expand Down Expand Up @@ -2607,7 +2605,7 @@ public:
} else if constexpr (_Del == _Deletion_kind::_Normal_array) {
delete[] _Ptr;
} else {
static_assert(_Always_false<_Ty>, "Unknown _Deletion_kind.");
static_assert(false, "Unknown _Deletion_kind.");
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_Own) {
return owning_view{_STD forward<_Rng>(_Range)};
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
};
Expand Down Expand Up @@ -2164,7 +2164,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_As_rvalue) {
return as_rvalue_view{_STD forward<_Rng>(_Range)};
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
};
Expand Down Expand Up @@ -3142,7 +3142,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_Reconstruct_subrange) {
return subrange(_First, _First + _Count);
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
}
Expand Down Expand Up @@ -3548,7 +3548,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_Reconstruct_other) {
return remove_cvref_t<_Rng>(_RANGES begin(_Range) + _Count, _RANGES end(_Range));
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
}
Expand Down Expand Up @@ -5389,7 +5389,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_Common) {
return common_view{_STD forward<_Rng>(_Range)};
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
};
Expand Down Expand Up @@ -5548,7 +5548,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_Reverse) {
return reverse_view{_STD forward<_Rng>(_Range)};
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
};
Expand Down Expand Up @@ -5692,7 +5692,7 @@ namespace ranges {
} else if constexpr (_Strat == _St::_As_const) {
return as_const_view{_STD forward<_Rng>(_Range)};
} else {
static_assert(_Always_false<_Rng>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
}
};
Expand Down Expand Up @@ -10369,7 +10369,7 @@ namespace ranges {
};
return _RANGES to<_Container>(views::transform(ref_view{_Range}, _Xform), _STD forward<_Types>(_Args)...);
} else {
static_assert(_Always_false<_Container>, "the program is ill-formed per N4950 [range.utility.conv.to]/2.3");
static_assert(false, "the program is ill-formed per N4950 [range.utility.conv.to]/2.3");
}
}

Expand Down
16 changes: 8 additions & 8 deletions stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ _NODISCARD constexpr _Ty& get(tuple<_Types...>& _Tuple) noexcept {
using _Ttype = typename tuple_element<_Idx, tuple<_Types...>>::_Ttype;
return static_cast<_Ttype&>(_Tuple)._Myfirst._Val;
} else {
static_assert(_Always_false<_Ty>,
"get<T>(tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
static_assert(
false, "get<T>(tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
}
}

Expand All @@ -966,8 +966,8 @@ _NODISCARD constexpr const _Ty& get(const tuple<_Types...>& _Tuple) noexcept {
using _Ttype = typename tuple_element<_Idx, tuple<_Types...>>::_Ttype;
return static_cast<const _Ttype&>(_Tuple)._Myfirst._Val;
} else {
static_assert(_Always_false<_Ty>,
"get<T>(const tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
static_assert(
false, "get<T>(const tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
}
}

Expand All @@ -978,8 +978,8 @@ _NODISCARD constexpr _Ty&& get(tuple<_Types...>&& _Tuple) noexcept {
using _Ttype = typename tuple_element<_Idx, tuple<_Types...>>::_Ttype;
return static_cast<_Ty&&>(static_cast<_Ttype&>(_Tuple)._Myfirst._Val);
} else {
static_assert(_Always_false<_Ty>,
"get<T>(tuple<Types...>&&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
static_assert(
false, "get<T>(tuple<Types...>&&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
}
}

Expand All @@ -990,8 +990,8 @@ _NODISCARD constexpr const _Ty&& get(const tuple<_Types...>&& _Tuple) noexcept {
using _Ttype = typename tuple_element<_Idx, tuple<_Types...>>::_Ttype;
return static_cast<const _Ty&&>(static_cast<const _Ttype&>(_Tuple)._Myfirst._Val);
} else {
static_assert(_Always_false<_Ty>,
"get<T>(const tuple<Types...>&&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
static_assert(
false, "get<T>(const tuple<Types...>&&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)");
}
}

Expand Down
5 changes: 2 additions & 3 deletions stl/inc/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ _STL_DISABLE_CLANG_WARNINGS

_STD_BEGIN
template <class>
// TRANSITION, CWG-2518: false value attached to a dependent name (for static_assert)
constexpr bool _Always_false = false;
constexpr bool _Always_false = false; // TRANSITION, VSO-2016422 (EDG)

template <bool _First_value, class _First, class... _Rest>
struct _Conjunction { // handle false trait or last trait
Expand Down Expand Up @@ -129,7 +128,7 @@ using add_rvalue_reference_t = typename _Add_reference<_Ty>::_Rvalue;

_EXPORT_STD template <class _Ty>
add_rvalue_reference_t<_Ty> declval() noexcept {
static_assert(_Always_false<_Ty>, "Calling declval is ill-formed, see N4950 [declval]/2.");
static_assert(false, "Calling declval is ill-formed, see N4950 [declval]/2.");
}

_EXPORT_STD template <class _Ty>
Expand Down
20 changes: 10 additions & 10 deletions stl/inc/variant
Original file line number Diff line number Diff line change
Expand Up @@ -1143,8 +1143,8 @@ _NODISCARD constexpr bool holds_alternative(const variant<_Types...>& _Var) noex
if constexpr (_Idx != _Meta_npos) {
return _Var.index() == _Idx;
} else {
static_assert(_Always_false<_Ty>, "holds_alternative<T>(const variant<Types...>&) requires T to occur exactly "
"once in Types. (N4971 [variant.get]/1)");
static_assert(false, "holds_alternative<T>(const variant<Types...>&) requires T to occur exactly "
"once in Types. (N4971 [variant.get]/1)");
}
}

Expand Down Expand Up @@ -1196,8 +1196,8 @@ _NODISCARD constexpr decltype(auto) get(variant<_Types...>& _Var) {
if constexpr (_Idx < sizeof...(_Types)) {
return _STD get<_Idx>(_Var);
} else {
static_assert(_Always_false<_Ty>,
"get<T>(variant<Types...>&) requires T to occur exactly once in Types. (N4971 [variant.get]/8)");
static_assert(
false, "get<T>(variant<Types...>&) requires T to occur exactly once in Types. (N4971 [variant.get]/8)");
}
}
_EXPORT_STD template <class _Ty, class... _Types>
Expand All @@ -1207,8 +1207,8 @@ _NODISCARD constexpr decltype(auto) get(variant<_Types...>&& _Var) {
if constexpr (_Idx < sizeof...(_Types)) {
return _STD get<_Idx>(_STD move(_Var));
} else {
static_assert(_Always_false<_Ty>,
"get<T>(variant<Types...>&&) requires T to occur exactly once in Types. (N4971 [variant.get]/8)");
static_assert(
false, "get<T>(variant<Types...>&&) requires T to occur exactly once in Types. (N4971 [variant.get]/8)");
}
}
_EXPORT_STD template <class _Ty, class... _Types>
Expand All @@ -1218,7 +1218,7 @@ _NODISCARD constexpr decltype(auto) get(const variant<_Types...>& _Var) {
if constexpr (_Idx < sizeof...(_Types)) {
return _STD get<_Idx>(_Var);
} else {
static_assert(_Always_false<_Ty>,
static_assert(false,
"get<T>(const variant<Types...>&) requires T to occur exactly once in Types. (N4971 [variant.get]/8)");
}
}
Expand All @@ -1229,7 +1229,7 @@ _NODISCARD constexpr decltype(auto) get(const variant<_Types...>&& _Var) {
if constexpr (_Idx < sizeof...(_Types)) {
return _STD get<_Idx>(_STD move(_Var));
} else {
static_assert(_Always_false<_Ty>,
static_assert(false,
"get<T>(const variant<Types...>&&) requires T to occur exactly once in Types. (N4971 [variant.get]/8)");
}
}
Expand All @@ -1254,7 +1254,7 @@ _NODISCARD constexpr add_pointer_t<_Ty> get_if(variant<_Types...>* _Ptr) noexcep
if constexpr (_Idx != _Meta_npos) {
return _STD get_if<_Idx>(_Ptr);
} else {
static_assert(_Always_false<_Ty>,
static_assert(false,
"get_if<T>(variant<Types...> *) requires T to occur exactly once in Types. (N4971 [variant.get]/12)");
}
}
Expand All @@ -1265,7 +1265,7 @@ _NODISCARD constexpr add_pointer_t<const _Ty> get_if(const variant<_Types...>* _
if constexpr (_Idx != _Meta_npos) {
return _STD get_if<_Idx>(_Ptr);
} else {
static_assert(_Always_false<_Ty>,
static_assert(false,
"get_if<T>(const variant<Types...> *) requires T to occur exactly once in Types. (N4971 [variant.get]/12)");
}
}
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/vector
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,7 @@ private:
} else if constexpr (sizeof...(_Val) == 2) {
_My_data._Mylast = _STD _Uninitialized_copy(_STD forward<_Valty>(_Val)..., _My_data._Myfirst, _Al);
} else {
static_assert(_Always_false<_Ty>, "Should be unreachable");
static_assert(false, "Should be unreachable");
}
_ASAN_VECTOR_CREATE;
_Guard._Target = nullptr;
Expand Down
Loading

0 comments on commit 1955118

Please sign in to comment.