Skip to content

Commit 43b927f

Browse files
committed
Add default init
1 parent 9e6e33d commit 43b927f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/xrpl/basics/Mutex.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ template <typename ProtectedDataType, typename MutexType = std::mutex>
101101
class Mutex
102102
{
103103
mutable MutexType mutex_;
104-
ProtectedDataType data_;
104+
ProtectedDataType data_{};
105105

106106
public:
107107
Mutex() = default;

src/tests/libxrpl/basics/Mutex.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
#include <gtest/gtest.h>
44

5+
#include <memory>
56
#include <mutex>
67
#include <shared_mutex>
78
#include <string>
89
#include <vector>
9-
#include <memory>
1010

1111
using namespace xrpl;
1212

@@ -56,6 +56,13 @@ TEST_F(MutexDirectConstructionTest, default_constructor)
5656
EXPECT_TRUE(lock->empty());
5757
}
5858

59+
TEST_F(MutexDirectConstructionTest, default_initialization)
60+
{
61+
Mutex<int> m;
62+
auto lock = m.lock();
63+
EXPECT_EQ(*lock, 0);
64+
}
65+
5966
TEST_F(MutexDirectConstructionTest, constructor_with_value)
6067
{
6168
Mutex<int> m(42);

0 commit comments

Comments
 (0)