Skip to content

Commit 53bbf5d

Browse files
committed
separate definitions of comparisons
1 parent 40d0aff commit 53bbf5d

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

libmamba/include/mamba/util/synchronized_value.hpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -440,23 +440,13 @@ namespace mamba::util
440440
/** Locks (shared if possible) and compare equality of the stored object's value with the
441441
provided value.
442442
*/
443-
auto operator==(const std::equality_comparable_with<T> auto& other_value) const -> bool
444-
{
445-
auto _ = lock_as_readonly(m_mutex);
446-
return m_value == other_value;
447-
}
443+
auto operator==(const std::equality_comparable_with<T> auto& other_value) const -> bool;
448444

449-
/** Locks (shared if possible) and compare equality of the stored object's value with the
445+
/** Locks both (shared if possible) and compare equality of the stored object's value with the
450446
provided value.
451447
*/
452448
template <std::equality_comparable_with<T> U, Mutex OtherMutex>
453-
auto operator==(const synchronized_value<U, OtherMutex>& other_value) const -> bool
454-
{
455-
auto this_lock [[maybe_unused]] = lock_as_readonly(m_mutex);
456-
auto other_lock [[maybe_unused]] = lock_as_readonly(other_value.m_mutex);
457-
458-
return m_value == other_value.m_value;
459-
}
449+
auto operator==(const synchronized_value<U, OtherMutex>& other_value) const -> bool;
460450

461451
auto swap(synchronized_value& other) -> void;
462452
auto swap(T& value) -> void;
@@ -568,6 +558,26 @@ namespace mamba::util
568558
return std::invoke(std::forward<Func>(func), std::as_const(m_value), std::forward<Args>(args)...);
569559
}
570560

561+
template <std::default_initializable T, Mutex M>
562+
auto synchronized_value<T, M>::operator==(const std::equality_comparable_with<T> auto& other_value
563+
) const -> bool
564+
{
565+
auto _ = lock_as_readonly(m_mutex);
566+
return m_value == other_value;
567+
}
568+
569+
template <std::default_initializable T, Mutex M>
570+
template <std::equality_comparable_with<T> U, Mutex OtherMutex>
571+
auto
572+
synchronized_value<T, M>::operator==(const synchronized_value<U, OtherMutex>& other_value) const
573+
-> bool
574+
{
575+
auto this_lock [[maybe_unused]] = lock_as_readonly(m_mutex);
576+
auto other_lock [[maybe_unused]] = lock_as_readonly(other_value.m_mutex);
577+
578+
return m_value == other_value.m_value;
579+
}
580+
571581
template <std::default_initializable T, Mutex M>
572582
auto synchronized_value<T, M>::swap(synchronized_value& other) -> void
573583
{

0 commit comments

Comments
 (0)