From 1b0b2cc86abdd061789132f8b642cf19327c2cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Mon, 30 Dec 2024 20:13:59 -0800 Subject: [PATCH] Added [[msvc::intrisic]]. --- include/bx/inline/typetraits.inl | 6 +++--- include/bx/macros.h | 3 +++ include/bx/typetraits.h | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/bx/inline/typetraits.inl b/include/bx/inline/typetraits.inl index a26ca1e..b0412e7 100644 --- a/include/bx/inline/typetraits.inl +++ b/include/bx/inline/typetraits.inl @@ -577,19 +577,19 @@ namespace bx //--- template - inline constexpr RemoveReferenceType&& move(Ty&& _a) + [[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr RemoveReferenceType&& move(Ty&& _a) { return static_cast&&>(_a); } template - inline constexpr Ty&& forward(RemoveReferenceType& _a) + [[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceType& _a) { return static_cast(_a); } template - inline constexpr Ty&& forward(RemoveReferenceType&& _a) + [[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceType&& _a) { static_assert(!isLvalueReference(), "Can not forward an Rvalue as an Lvalue."); return static_cast(_a); diff --git a/include/bx/macros.h b/include/bx/macros.h index c53895e..b71d529 100644 --- a/include/bx/macros.h +++ b/include/bx/macros.h @@ -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 diff --git a/include/bx/typetraits.h b/include/bx/typetraits.h index 9460000..5b3fc15 100644 --- a/include/bx/typetraits.h +++ b/include/bx/typetraits.h @@ -273,15 +273,15 @@ namespace bx /// Removes reference from type `Ty` if present. template - constexpr RemoveReferenceType&& move(Ty&& _a); + [[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr RemoveReferenceType&& move(Ty&& _a); /// Forwards Lvalues as either Lvalues or as Rvalues. template - constexpr Ty&& forward(RemoveReferenceType& _type); + [[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceType& _type); /// Forwards Rvalues as Rvalues and prohibits forwarding of Rvalues as Lvalues. template - constexpr Ty&& forward(RemoveReferenceT&& _type); + [[nodiscard]] BX_ATTRIBUTE_INTRINSIC constexpr Ty&& forward(RemoveReferenceT&& _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.