Skip to content

Commit

Permalink
Added [[msvc::intrisic]].
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Dec 31, 2024
1 parent df86c61 commit 1b0b2cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/bx/inline/typetraits.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions include/bx/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/bx/typetraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1b0b2cc

Please sign in to comment.