Бранимир Караџић пре 4 година
родитељ
комит
3f9dc88e64
2 измењених фајлова са 14 додато и 0 уклоњено
  1. 4 0
      include/bx/bx.h
  2. 10 0
      include/bx/inline/bx.inl

+ 4 - 0
include/bx/bx.h

@@ -38,6 +38,10 @@ namespace bx
 	template<class Ty>
 	template<class Ty>
 	constexpr bool isTriviallyCopyable();
 	constexpr bool isTriviallyCopyable();
 
 
+	/// Find the address of an object of a class that has an overloaded unary ampersand (&) operator.
+	template <class Ty>
+	Ty* addressOf(Ty& _a);
+
 	/// Swap two values.
 	/// Swap two values.
 	template<typename Ty>
 	template<typename Ty>
 	void swap(Ty& _a, Ty& _b);
 	void swap(Ty& _a, Ty& _b);

+ 10 - 0
include/bx/inline/bx.inl

@@ -33,6 +33,16 @@ namespace bx
 		return __is_trivially_copyable(Ty);
 		return __is_trivially_copyable(Ty);
 	}
 	}
 
 
+	template<class Ty>
+	inline Ty* addressOf(Ty& _a)
+	{
+		return reinterpret_cast<Ty*>(
+				&const_cast<char&>(
+					reinterpret_cast<const volatile char&>(_a)
+				)
+			);
+	}
+
 	template<typename Ty>
 	template<typename Ty>
 	inline void swap(Ty& _a, Ty& _b)
 	inline void swap(Ty& _a, Ty& _b)
 	{
 	{