mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added bx::addressOf.
This commit is contained in:
@@ -38,6 +38,10 @@ namespace bx
|
||||
template<class Ty>
|
||||
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.
|
||||
template<typename Ty>
|
||||
void swap(Ty& _a, Ty& _b);
|
||||
|
||||
@@ -33,6 +33,16 @@ namespace bx
|
||||
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>
|
||||
inline void swap(Ty& _a, Ty& _b)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user