Added [[msvc::intrisic]].

This commit is contained in:
Бранимир Караџић
2024-12-30 20:13:59 -08:00
parent df86c611d7
commit 1b0b2cc86a
3 changed files with 9 additions and 6 deletions

View File

@@ -577,19 +577,19 @@ namespace bx
//---
template<typename Ty>
inline constexpr RemoveReferenceType<Ty>&& move(Ty&& _a)
[[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr RemoveReferenceType<Ty>&& move(Ty&& _a)
{
return static_cast<RemoveReferenceType<Ty>&&>(_a);
}
template<typename Ty>
inline constexpr Ty&& forward(RemoveReferenceType<Ty>& _a)
[[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceType<Ty>& _a)
{
return static_cast<Ty&&>(_a);
}
template<typename Ty>
inline constexpr Ty&& forward(RemoveReferenceType<Ty>&& _a)
[[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceType<Ty>&& _a)
{
static_assert(!isLvalueReference<Ty>(), "Can not forward an Rvalue as an Lvalue.");
return static_cast<Ty&&>(_a);

View File

@@ -61,6 +61,7 @@
# define BX_PRINTF_ARGS(_format, _args) __attribute__( (format(__printf__, _format, _args) ) )
# define BX_THREAD_LOCAL __thread
# define BX_ATTRIBUTE(_x) __attribute__( (_x) )
# define BX_ATTRIBUTE_INTRINSIC BX_FORCE_INLINE
# define BX_STACK_ALLOC(_size) __builtin_alloca(_size)
# if BX_CRT_MSVC
@@ -81,6 +82,8 @@
# define BX_PRINTF_ARGS(_format, _args)
# define BX_THREAD_LOCAL __declspec(thread)
# define BX_ATTRIBUTE(_x)
# define BX_ATTRIBUTE_INTRINSIC [[msvc::intrinsic]]
extern "C" void* __cdecl _alloca(size_t _size);
# define BX_STACK_ALLOC(_size) ::_alloca(_size)
#else

View File

@@ -273,15 +273,15 @@ namespace bx
/// Removes reference from type `Ty` if present.
template<typename Ty>
constexpr RemoveReferenceType<Ty>&& move(Ty&& _a);
[[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr RemoveReferenceType<Ty>&& move(Ty&& _a);
/// Forwards Lvalues as either Lvalues or as Rvalues.
template<typename Ty>
constexpr Ty&& forward(RemoveReferenceType<Ty>& _type);
[[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceType<Ty>& _type);
/// Forwards Rvalues as Rvalues and prohibits forwarding of Rvalues as Lvalues.
template<typename Ty>
constexpr Ty&& forward(RemoveReferenceT<Ty>&& _type);
[[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceT<Ty>&& _type);
/// Converts any type `Ty` to a reference type, making it possible to use member functions
/// in decltype expressions without the need to go through constructors.