AuROXTL/Include/auROXTL/auSwapExchangeUtils.hpp

24 lines
503 B
C++
Raw Normal View History

2022-04-01 04:06:53 +00:00
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auSwapExchangeUtils.hpp
Date: 2022-3-27
Author: Reece
***/
#pragma once
template <class T, class U = T>
inline T AuExchange(T &obj, U &&newValue)
{
T oldValue = AuMove(obj);
obj = AuForward<U>(newValue);
return oldValue;
}
#if !defined(AURORA_RUNTIME_SWAP)
#define AURORA_RUNTIME_SWAP std::swap
#endif
template <class T>
inline void AuSwap(T &a, T &b)
{
AURORA_RUNTIME_SWAP(a, b);
}