Skip to content

Commit 72eedeb

Browse files
committed
fix(log): use constructor template instead of class template for initiator
- src/libipc/platform/win/get_sa.h: * Change from class template to constructor template * Keep 'struct initiator' as a regular class (not template) * Make constructor a function template: template <typename Logger> initiator(Logger const &log) * Instantiate as: static initiator handle(log); * This is valid C++ as function templates can be defined inside functions * Fixes the issue that class templates cannot be defined inside functions The constructor template approach allows proper logger passing while maintaining valid C++ syntax for local struct definitions.
1 parent afd1467 commit 72eedeb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libipc/platform/win/get_sa.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ namespace detail {
88
inline LPSECURITY_ATTRIBUTES get_sa() {
99
LIBIPC_LOG();
1010

11-
template <typename Logger>
1211
struct initiator {
1312
SECURITY_DESCRIPTOR sd_;
1413
SECURITY_ATTRIBUTES sa_;
1514
bool succ_ = false;
1615

16+
template <typename Logger>
1717
initiator(Logger const &log) {
1818
if (!::InitializeSecurityDescriptor(&sd_, SECURITY_DESCRIPTOR_REVISION)) {
1919
log.error("fail InitializeSecurityDescriptor[", static_cast<int>(::GetLastError()), "]");
@@ -30,7 +30,7 @@ inline LPSECURITY_ATTRIBUTES get_sa() {
3030
}
3131
};
3232

33-
static initiator<decltype(log)> handle(log);
33+
static initiator handle(log);
3434
return handle.succ_ ? &handle.sa_ : nullptr;
3535
}
3636

0 commit comments

Comments
 (0)