We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f939b2c commit 3f9dc88Copy full SHA for 3f9dc88
include/bx/bx.h
@@ -38,6 +38,10 @@ namespace bx
38
template<class Ty>
39
constexpr bool isTriviallyCopyable();
40
41
+ /// Find the address of an object of a class that has an overloaded unary ampersand (&) operator.
42
+ template <class Ty>
43
+ Ty* addressOf(Ty& _a);
44
+
45
/// Swap two values.
46
template<typename Ty>
47
void swap(Ty& _a, Ty& _b);
include/bx/inline/bx.inl
@@ -33,6 +33,16 @@ namespace bx
33
return __is_trivially_copyable(Ty);
34
}
35
36
+ template<class Ty>
37
+ inline Ty* addressOf(Ty& _a)
+ {
+ return reinterpret_cast<Ty*>(
+ &const_cast<char&>(
+ reinterpret_cast<const volatile char&>(_a)
+ )
+ );
+ }
inline void swap(Ty& _a, Ty& _b)
48
{
0 commit comments