forked from github/verilator
Fix std::exchange for C++11 compilers
This commit is contained in:
parent
2a12b052f2
commit
c9634695a7
@ -1113,7 +1113,7 @@ public:
|
||||
refCountInc();
|
||||
}
|
||||
VlClassRef(VlClassRef&& moved)
|
||||
: m_objp{std::exchange(moved.m_objp, nullptr)} {}
|
||||
: m_objp{vlstd::exchange(moved.m_objp, nullptr)} {}
|
||||
~VlClassRef() { refCountDec(); }
|
||||
|
||||
// METHODS
|
||||
@ -1126,7 +1126,7 @@ public:
|
||||
}
|
||||
VlClassRef& operator=(VlClassRef&& moved) {
|
||||
refCountDec();
|
||||
m_objp = std::exchange(moved.m_objp, nullptr);
|
||||
m_objp = vlstd::exchange(moved.m_objp, nullptr);
|
||||
return *this;
|
||||
}
|
||||
template <typename T_OtherClass>
|
||||
@ -1139,7 +1139,7 @@ public:
|
||||
template <typename T_OtherClass>
|
||||
VlClassRef& operator=(VlClassRef<T_OtherClass>&& moved) {
|
||||
refCountDec();
|
||||
m_objp = std::exchange(moved.m_objp, nullptr);
|
||||
m_objp = vlstd::exchange(moved.m_objp, nullptr);
|
||||
return *this;
|
||||
}
|
||||
// Dynamic caster
|
||||
|
@ -540,6 +540,8 @@ using ssize_t = uint32_t; ///< signed size_t; returned from read()
|
||||
//=========================================================================
|
||||
// Conversions
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace vlstd {
|
||||
|
||||
template <typename T>
|
||||
@ -564,6 +566,14 @@ T const& as_const(T& v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
// C++14's std::exchange
|
||||
template <class T, class U = T>
|
||||
T exchange(T& obj, U&& new_value) {
|
||||
T old_value = std::move(obj);
|
||||
obj = std::forward<U>(new_value);
|
||||
return old_value;
|
||||
}
|
||||
|
||||
}; // namespace vlstd
|
||||
|
||||
//=========================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user