Skip to content
Snippets Groups Projects

add move constructor to SynchronizedValue

Merged Gerhard Raven requested to merge allow-move-ctor-SynchronizedValue into master
1 file
+ 18
0
Compare changes
  • Side-by-side
  • Inline
@@ -59,6 +59,24 @@ namespace LHCb::cxx {
return *this;
}
SynchronizedValue( SynchronizedValue&& rhs ) {
static_assert( std::is_default_constructible_v<Value> ); // bound to hold, as otherwise we wouldn't get this
// far... so for 'documnentation purpose' really (C++20:
// turn into a `requires` clause )...
static_assert( std::is_move_assignable_v<Value> );
auto lock = std::scoped_lock{rhs.m_mtx, m_mtx};
m_obj = std::move( rhs.m_obj );
}
SynchronizedValue& operator=( SynchronizedValue&& rhs ) {
static_assert( std::is_move_assignable_v<Value> );
if ( this != &rhs ) {
auto lock = std::scoped_lock{rhs.m_mtx, m_mtx};
m_obj = std::move( rhs.m_obj );
}
return *this;
}
template <typename F, typename... Args,
typename = std::enable_if_t<std::is_invocable_v<F, Value&, Args...> &&
!std::is_invocable_v<F, const Value&, Args...>>>
Loading