Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
petrhosek committed Jul 15, 2024
1 parent cd00542 commit 757a485
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#include <cassert>
#include "test_macros.h"

struct Lock {
struct MyMutex {
bool locked = false;

Lock() = default;
~Lock() { assert(!locked); }
MyMutex() = default;
~MyMutex() { assert(!locked); }

void lock() {
assert(!locked);
Expand All @@ -35,21 +35,21 @@ struct Lock {
locked = false;
}

Lock(Lock const&) = delete;
Lock& operator=(Lock const&) = delete;
MyMutex(MyMutex const&) = delete;
MyMutex& operator=(MyMutex const&) = delete;
};

int main(int, char**) {
Lock l;
MyMutex m;
{
std::lock_guard<Lock> lg(l);
assert(l.locked);
std::lock_guard<MyMutex> lg(m);
assert(m.locked);
}
assert(!l.locked);
assert(!m.locked);

#if TEST_STD_VER >= 17
std::lock_guard lg(l);
static_assert((std::is_same<decltype(l), std::lock_guard<decltype(l)>>::value), "");
std::lock_guard lg(m);
static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "");
#endif

return 0;
Expand Down

0 comments on commit 757a485

Please sign in to comment.