Selaa lähdekoodia

Added [[msvc::intrisic]].

Бранимир Караџић 11 kuukautta sitten
vanhempi
sitoutus
1b0b2cc86a
3 muutettua tiedostoa jossa 9 lisäystä ja 6 poistoa
  1. 3 3
      include/bx/inline/typetraits.inl
  2. 3 0
      include/bx/macros.h
  3. 3 3
      include/bx/typetraits.h

+ 3 - 3
include/bx/inline/typetraits.inl

@@ -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);

+ 3 - 0
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

+ 3 - 3
include/bx/typetraits.h

@@ -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.