add [[msvc::intrinsic]] for some cast funcs. (#3664)

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Co-authored-by: A. Jiang <de34@live.cn>
This commit is contained in:
clundro 2023-07-21 07:32:59 +08:00 коммит произвёл GitHub
Родитель f51733ca53
Коммит ef8baca38b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -19,6 +19,12 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
// TRANSITION, non-_Ugly attribute tokens
#pragma push_macro("msvc")
#pragma push_macro("intrinsic")
#undef msvc
#undef intrinsic
_STD_BEGIN
_EXPORT_STD using _CSTD ptrdiff_t;
_EXPORT_STD using _CSTD size_t;
@ -86,7 +92,7 @@ _EXPORT_STD constexpr byte& operator^=(byte& _Left, const byte _Right) noexcept
}
_EXPORT_STD template <class _IntType, enable_if_t<is_integral_v<_IntType>, int> = 0>
_NODISCARD constexpr _IntType to_integer(const byte _Arg) noexcept {
_NODISCARD _MSVC_INTRINSIC constexpr _IntType to_integer(const byte _Arg) noexcept {
return static_cast<_IntType>(_Arg);
}
#endif // __cpp_lib_byte
@ -95,6 +101,10 @@ _STD_END
using _STD max_align_t; // intentional, for historical reasons
// TRANSITION, non-_Ugly attribute tokens
#pragma pop_macro("intrinsic")
#pragma pop_macro("msvc")
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)

Просмотреть файл

@ -766,7 +766,7 @@ _CONSTEXPR20 _Ty exchange(_Ty& _Val, _Other&& _New_val) noexcept(
}
_EXPORT_STD template <class _Ty>
_NODISCARD constexpr add_const_t<_Ty>& as_const(_Ty& _Val) noexcept { // view _Val through const lenses
_NODISCARD _MSVC_INTRINSIC constexpr add_const_t<_Ty>& as_const(_Ty& _Val) noexcept { // view _Val through const lenses
return _Val;
}
@ -917,7 +917,7 @@ inline constexpr bool _Can_reference<_Ty, void_t<_Ty&>> = true;
#if _HAS_CXX23
_EXPORT_STD template <class _Ty>
_NODISCARD constexpr underlying_type_t<_Ty> to_underlying(_Ty _Value) noexcept {
_NODISCARD _MSVC_INTRINSIC constexpr underlying_type_t<_Ty> to_underlying(_Ty _Value) noexcept {
return static_cast<underlying_type_t<_Ty>>(_Value);
}

Просмотреть файл

@ -23,7 +23,9 @@ _STL_DISABLE_CLANG_WARNINGS
// TRANSITION, non-_Ugly attribute tokens
#pragma push_macro("msvc")
#pragma push_macro("intrinsic")
#undef msvc
#undef intrinsic
#if defined(_CRTBLD) && defined(CRTDLL2)
// TRANSITION, ABI: The vector algorithms are compiled into the import lib, so we disable their usage when building
@ -2667,7 +2669,7 @@ namespace ranges {
concept constant_range = input_range<_Rng> && _Constant_iterator<iterator_t<_Rng>>;
template <input_range _Rng>
_NODISCARD constexpr auto& _Possibly_const_range(_Rng& _Range) noexcept {
_NODISCARD _MSVC_INTRINSIC constexpr auto& _Possibly_const_range(_Rng& _Range) noexcept {
if constexpr (constant_range<const _Rng> && !constant_range<_Rng>) {
return _STD as_const(_Range);
} else {
@ -2676,7 +2678,7 @@ namespace ranges {
}
template <class _Ty>
_NODISCARD constexpr auto _As_const_pointer(const _Ty* _Ptr) noexcept {
_NODISCARD _MSVC_INTRINSIC constexpr auto _As_const_pointer(const _Ty* _Ptr) noexcept {
return _Ptr;
}
#endif // _HAS_CXX23
@ -7239,6 +7241,7 @@ _NODISCARD constexpr bool _Mul_overflow(const _Int _Left, const _Int _Right, _In
_STD_END
// TRANSITION, non-_Ugly attribute tokens
#pragma pop_macro("intrinsic")
#pragma pop_macro("msvc")
#pragma pop_macro("new")