From caee95ac9aec8cb0fdcd88a5f5e6661f4c619642 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Jun 2020 10:25:01 -0700 Subject: [PATCH] Fix conflicts with std::swap. --- mathlib/mathlib_base.cpp | 18 +++++++++--------- public/mathlib/mathlib.h | 2 +- public/particles/particles.h | 2 +- public/tier1/utlblockmemory.h | 8 ++++---- public/tier1/utlfixedmemory.h | 6 +++--- public/tier1/utlmemory.h | 6 +++--- public/tier1/utlrbtree.h | 12 ++++++------ public/tier1/utlvector.h | 6 +++--- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/mathlib/mathlib_base.cpp b/mathlib/mathlib_base.cpp index 4efbc980..e57e6c92 100644 --- a/mathlib/mathlib_base.cpp +++ b/mathlib/mathlib_base.cpp @@ -380,9 +380,9 @@ void MatrixInvert( const matrix3x4_t& in, matrix3x4_t& out ) Assert( s_bMathlibInitialized ); if ( &in == &out ) { - swap(out[0][1],out[1][0]); - swap(out[0][2],out[2][0]); - swap(out[1][2],out[2][1]); + V_swap(out[0][1],out[1][0]); + V_swap(out[0][2],out[2][0]); + V_swap(out[1][2],out[2][1]); } else { @@ -1264,18 +1264,18 @@ bool SolveInverseQuadraticMonotonic( float x1, float y1, float x2, float y2, flo // first, sort parameters if (x1>x2) { - swap(x1,x2); - swap(y1,y2); + V_swap(x1,x2); + V_swap(y1,y2); } if (x2>x3) { - swap(x2,x3); - swap(y2,y3); + V_swap(x2,x3); + V_swap(y2,y3); } if (x1>x2) { - swap(x1,x2); - swap(y1,y2); + V_swap(x1,x2); + V_swap(y1,y2); } // this code is not fast. what it does is when the curve would be non-monotonic, slowly shifts // the center point closer to the linear line between the endpoints. Should anyone need htis diff --git a/public/mathlib/mathlib.h b/public/mathlib/mathlib.h index f8f7ccb9..7b24b1ad 100644 --- a/public/mathlib/mathlib.h +++ b/public/mathlib/mathlib.h @@ -608,7 +608,7 @@ template<> FORCEINLINE QAngleByValue Lerp( float flPercent, const // Swap two of anything. template -FORCEINLINE void swap( T& x, T& y ) +FORCEINLINE void V_swap( T& x, T& y ) { T temp = x; x = y; diff --git a/public/particles/particles.h b/public/particles/particles.h index 45cb145f..6078a636 100644 --- a/public/particles/particles.h +++ b/public/particles/particles.h @@ -1452,7 +1452,7 @@ inline void CParticleCollection::SwapPosAndPrevPos( void ) { // strides better be the same! Assert( m_nParticleFloatStrides[PARTICLE_ATTRIBUTE_XYZ] == m_nParticleFloatStrides[ PARTICLE_ATTRIBUTE_PREV_XYZ ] ); - swap( m_pParticleAttributes[ PARTICLE_ATTRIBUTE_XYZ ], m_pParticleAttributes[ PARTICLE_ATTRIBUTE_PREV_XYZ ] ); + V_swap( m_pParticleAttributes[ PARTICLE_ATTRIBUTE_XYZ ], m_pParticleAttributes[ PARTICLE_ATTRIBUTE_PREV_XYZ ] ); } inline void CParticleCollection::LoanKillListTo( CParticleCollection *pBorrower ) const diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h index 7f08c40b..19b34c72 100644 --- a/public/tier1/utlblockmemory.h +++ b/public/tier1/utlblockmemory.h @@ -137,10 +137,10 @@ CUtlBlockMemory::~CUtlBlockMemory() template< class T, class I > void CUtlBlockMemory::Swap( CUtlBlockMemory< T, I > &mem ) { - swap( m_pMemory, mem.m_pMemory ); - swap( m_nBlocks, mem.m_nBlocks ); - swap( m_nIndexMask, mem.m_nIndexMask ); - swap( m_nIndexShift, mem.m_nIndexShift ); + V_swap( m_pMemory, mem.m_pMemory ); + V_swap( m_nBlocks, mem.m_nBlocks ); + V_swap( m_nIndexMask, mem.m_nIndexMask ); + V_swap( m_nIndexShift, mem.m_nIndexShift ); } diff --git a/public/tier1/utlfixedmemory.h b/public/tier1/utlfixedmemory.h index c5587f07..bb84844d 100644 --- a/public/tier1/utlfixedmemory.h +++ b/public/tier1/utlfixedmemory.h @@ -181,9 +181,9 @@ CUtlFixedMemory::~CUtlFixedMemory() template< class T > void CUtlFixedMemory::Swap( CUtlFixedMemory< T > &mem ) { - swap( m_pBlocks, mem.m_pBlocks ); - swap( m_nAllocationCount, mem.m_nAllocationCount ); - swap( m_nGrowSize, mem.m_nGrowSize ); + V_swap( m_pBlocks, mem.m_pBlocks ); + V_swap( m_nAllocationCount, mem.m_nAllocationCount ); + V_swap( m_nGrowSize, mem.m_nGrowSize ); } diff --git a/public/tier1/utlmemory.h b/public/tier1/utlmemory.h index a55f571e..5b0c8ffb 100644 --- a/public/tier1/utlmemory.h +++ b/public/tier1/utlmemory.h @@ -327,9 +327,9 @@ void CUtlMemory::Init( int nGrowSize /*= 0*/, int nInitSize /*= 0*/ ) template< class T, class I > void CUtlMemory::Swap( CUtlMemory &mem ) { - swap( m_nGrowSize, mem.m_nGrowSize ); - swap( m_pMemory, mem.m_pMemory ); - swap( m_nAllocationCount, mem.m_nAllocationCount ); + V_swap( m_nGrowSize, mem.m_nGrowSize ); + V_swap( m_pMemory, mem.m_pMemory ); + V_swap( m_nAllocationCount, mem.m_nAllocationCount ); } diff --git a/public/tier1/utlrbtree.h b/public/tier1/utlrbtree.h index 1e401aaf..b9b49eb8 100644 --- a/public/tier1/utlrbtree.h +++ b/public/tier1/utlrbtree.h @@ -1547,12 +1547,12 @@ template < class T, class I, typename L, class M > void CUtlRBTree::Swap( CUtlRBTree< T, I, L > &that ) { m_Elements.Swap( that.m_Elements ); - swap( m_LessFunc, that.m_LessFunc ); - swap( m_Root, that.m_Root ); - swap( m_NumElements, that.m_NumElements ); - swap( m_FirstFree, that.m_FirstFree ); - swap( m_pElements, that.m_pElements ); - swap( m_LastAlloc, that.m_LastAlloc ); + V_swap( m_LessFunc, that.m_LessFunc ); + V_swap( m_Root, that.m_Root ); + V_swap( m_NumElements, that.m_NumElements ); + V_swap( m_FirstFree, that.m_FirstFree ); + V_swap( m_pElements, that.m_pElements ); + V_swap( m_LastAlloc, that.m_LastAlloc ); Assert( IsValid() ); Assert( m_Elements.IsValidIterator( m_LastAlloc ) || ( m_NumElements == 0 && m_FirstFree == InvalidIndex() ) ); } diff --git a/public/tier1/utlvector.h b/public/tier1/utlvector.h index 9dc4c6e9..3dd9186e 100644 --- a/public/tier1/utlvector.h +++ b/public/tier1/utlvector.h @@ -415,7 +415,7 @@ void CUtlVector::Sort( int (__cdecl *pfnCompare)(const T *, const T *) ) { if ( pfnCompare( &Element( j - 1 ), &Element( j ) ) < 0 ) { - swap( Element( j - 1 ), Element( j ) ); + V_swap( Element( j - 1 ), Element( j ) ); } } } @@ -605,8 +605,8 @@ template< typename T, class A > void CUtlVector::Swap( CUtlVector< T, A > &vec ) { m_Memory.Swap( vec.m_Memory ); - swap( m_Size, vec.m_Size ); - swap( m_pElements, vec.m_pElements ); + V_swap( m_Size, vec.m_Size ); + V_swap( m_pElements, vec.m_pElements ); } template< typename T, class A >