From f05986917a79aa8f844a2dcb5436a300ac5b3382 Mon Sep 17 00:00:00 2001 From: Justin King Date: Mon, 26 Oct 2026 17:20:50 -0700 Subject: [PATCH] Avoid specializing `std::default_delete` PiperOrigin-RevId: 1007675275 --- cel-c/activation.h | 21 ++++++++++----------- cel-c/ast.h | 18 ++++++++---------- cel-c/program.h | 19 +++++++++---------- cel-c/runtime.h | 19 +++++++++---------- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/cel-c/activation.h b/cel-c/activation.h index ebe55cc..699ab4f 100644 --- a/cel-c/activation.h +++ b/cel-c/activation.h @@ -80,19 +80,18 @@ CEL_EXTERN bool cel_Activation_Execute(cel_Activation* cel_nonnull activation, CEL_END_DECLS #ifdef __cplusplus -namespace std { -template <> -struct default_delete<::cel_Activation> { - template - CEL_INLINE void operator()(U* ptr) const noexcept { - ::cel_Activation_Delete(const_cast<::cel_Activation*>(ptr)); +struct cel_ActivationDeleter { + CEL_INLINE void operator()( + cel_Activation* cel_nullable activation) const noexcept { + cel_Activation_Delete(activation); + } + CEL_INLINE void operator()( + const cel_Activation* cel_nullable activation) const noexcept { + (*this)(const_cast(activation)); } }; -template <> -struct default_delete - : default_delete<::cel_Activation> {}; -} // namespace std -using cel_ActivationPtr = std::unique_ptr; +using cel_ActivationPtr = + std::unique_ptr; #endif #endif // THIRD_PARTY_CEL_C_ACTIVATION_H_ diff --git a/cel-c/ast.h b/cel-c/ast.h index aa1336c..9fff7c4 100644 --- a/cel-c/ast.h +++ b/cel-c/ast.h @@ -33,18 +33,16 @@ CEL_EXTERN void cel_Ast_Delete(cel_Ast* cel_nullable ast); CEL_END_DECLS #ifdef __cplusplus -namespace std { -template <> -struct default_delete<::cel_Ast> { - template - CEL_INLINE void operator()(U* ptr) const noexcept { - ::cel_Ast_Delete(const_cast<::cel_Ast*>(ptr)); +struct cel_AstDeleter { + CEL_INLINE void operator()(cel_Ast* cel_nullable activation) const noexcept { + cel_Ast_Delete(activation); + } + CEL_INLINE void operator()( + const cel_Ast* cel_nullable activation) const noexcept { + (*this)(const_cast(activation)); } }; -template <> -struct default_delete : default_delete<::cel_Ast> {}; -} // namespace std -using cel_AstPtr = std::unique_ptr; +using cel_AstPtr = std::unique_ptr; #endif #endif // THIRD_PARTY_CEL_C_AST_H_ diff --git a/cel-c/program.h b/cel-c/program.h index f3ba15e..1f06899 100644 --- a/cel-c/program.h +++ b/cel-c/program.h @@ -51,18 +51,17 @@ cel_Program_Activate(const cel_Program* cel_nonnull program, CEL_END_DECLS #ifdef __cplusplus -namespace std { -template <> -struct default_delete<::cel_Program> { - template - CEL_INLINE void operator()(U* ptr) const noexcept { - ::cel_Program_Delete(const_cast<::cel_Program*>(ptr)); +struct cel_ProgramDeleter { + CEL_INLINE void operator()( + cel_Program* cel_nullable activation) const noexcept { + cel_Program_Delete(activation); + } + CEL_INLINE void operator()( + const cel_Program* cel_nullable activation) const noexcept { + (*this)(const_cast(activation)); } }; -template <> -struct default_delete : default_delete<::cel_Program> {}; -} // namespace std -using cel_ProgramPtr = std::unique_ptr; +using cel_ProgramPtr = std::unique_ptr; #endif #endif // THIRD_PARTY_CEL_C_PROGRAM_H_ diff --git a/cel-c/runtime.h b/cel-c/runtime.h index 7a2b4cb..95cdb18 100644 --- a/cel-c/runtime.h +++ b/cel-c/runtime.h @@ -82,18 +82,17 @@ CEL_EXTERN cel_Program* cel_nullable cel_Runtime_Compile( CEL_END_DECLS #ifdef __cplusplus -namespace std { -template <> -struct default_delete<::cel_Runtime> { - template - CEL_INLINE void operator()(U* ptr) const noexcept { - ::cel_Runtime_Delete(const_cast<::cel_Runtime*>(ptr)); +struct cel_RuntimeDeleter { + CEL_INLINE void operator()( + cel_Runtime* cel_nullable activation) const noexcept { + cel_Runtime_Delete(activation); + } + CEL_INLINE void operator()( + const cel_Runtime* cel_nullable activation) const noexcept { + (*this)(const_cast(activation)); } }; -template <> -struct default_delete : default_delete<::cel_Runtime> {}; -} // namespace std -using cel_RuntimePtr = std::unique_ptr; +using cel_RuntimePtr = std::unique_ptr; #endif #endif // THIRD_PARTY_CEL_C_RUNTIME_H_