Skip to content

Commit 025311d

Browse files
t1h0nmutouyun
authored andcommitted
fix emplace construction for shm_data. Previous required copy constructor
1 parent 035d76d commit 025311d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/libipc/platform/linux/mutex.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ class mutex {
125125
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
126126
auto it = info.mutex_handles.find(name);
127127
if (it == info.mutex_handles.end()) {
128-
it = info.mutex_handles.emplace(name,
129-
curr_prog::shm_data::init{name}).first;
128+
it = info.mutex_handles
129+
.emplace(
130+
std::piecewise_construct, std::forward_as_tuple(name),
131+
std::forward_as_tuple(curr_prog::shm_data::init{name}))
132+
.first;
130133
}
131134
mutex_ = &it->second.mtx;
132135
ref_ = &it->second.ref;

src/libipc/platform/posix/mutex.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ class mutex {
5555
IPC_UNUSED_ std::lock_guard<std::mutex> guard {info.lock};
5656
auto it = info.mutex_handles.find(name);
5757
if (it == info.mutex_handles.end()) {
58-
it = info.mutex_handles.emplace(name,
59-
curr_prog::shm_data::init{name, sizeof(pthread_mutex_t)}).first;
58+
it = info.mutex_handles
59+
.emplace(std::piecewise_construct,
60+
std::forward_as_tuple(name),
61+
std::forward_as_tuple(curr_prog::shm_data::init{
62+
name, sizeof(pthread_mutex_t)}))
63+
.first;
6064
}
6165
shm_ = &it->second.shm;
6266
ref_ = &it->second.ref;

0 commit comments

Comments
 (0)