From a82e3faf63eb96f84489dd62d3e805744b97639d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E5=A4=B4=E4=BA=91?= Date: Sat, 6 Dec 2025 06:13:58 +0000 Subject: [PATCH] Fix C++17 compilation error on FreeBSD GCC 13.3 Remove custom deduction guides for std::unique_ptr in C++17 mode. Issue: FreeBSD GCC 13.3 correctly rejects adding deduction guides to namespace std, which violates C++ standard [namespace.std]: "The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std." Root cause: The code attempted to add custom deduction guides for std::unique_ptr in namespace std when compiling in C++17 mode. This is not allowed by the C++ standard. Solution: Remove the custom deduction guides for C++17 and later, as the C++17 standard library already provides deduction guides for std::unique_ptr (added in C++17 via P0433R2). The custom deduction guide wrappers in the else branch (for C++14 and earlier) are kept as they provide helper functions, not actual deduction guides in namespace std. Tested-on: FreeBSD 15 with GCC 13.3 Fixes: Compilation error 'deduction guide must be declared in the same scope as template std::unique_ptr' --- src/libipc/platform/detail.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libipc/platform/detail.h b/src/libipc/platform/detail.h index 69e6b89..17ccbb9 100755 --- a/src/libipc/platform/detail.h +++ b/src/libipc/platform/detail.h @@ -72,15 +72,9 @@ #if __cplusplus >= 201703L -namespace std { -// deduction guides for std::unique_ptr -template -unique_ptr(T* p) -> unique_ptr; -template -unique_ptr(T* p, D&& d) -> unique_ptr>; - -} // namespace std +// C++17 and later: std library already provides deduction guides +// No need to add custom ones, just use the standard ones directly namespace ipc { namespace detail {