Skip to content

Commit 4d11e78

Browse files
Small cleanups
1 parent 59080a2 commit 4d11e78

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

include/mlib/delete.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @brief C type deletion registration
44
* @date 2024-10-29
55
*
6-
* This file is used to define how to "delete" C types that acts as owners or
6+
* This file is used to define how to "delete" C types that acts as owners of
77
* resources.
88
*
99
* Refer to `dev/deletion` for details
@@ -12,10 +12,6 @@
1212

1313
#include <mlib/config.h>
1414

15-
#if mlib_is_cxx()
16-
#include <type_traits>
17-
#endif
18-
1915
/**
2016
* @brief Use inline within a struct to declare a deletion spec that invokes
2117
* a deletion on struct members. In C, expands to an empty declaration.
@@ -35,6 +31,7 @@
3531
}) \
3632
mlib_static_assert(true, "")
3733

34+
// clang-format off
3835
/**
3936
* @brief Declares a C API function `FuncName` that invokes the default deletion
4037
* method for `Type`.
@@ -47,10 +44,21 @@
4744
*/
4845
#define mlib_declare_c_deletion_function(FuncName, Type) \
4946
MLIB_IF_ELSE(mlib_have_cxx20()) \
47+
/*-
48+
* If C++ declare and define an inline deleter function that just invokes the delete_unique()
49+
* for the given type.
50+
*/ \
5051
(extern "C" MLIB_IF_GNU_LIKE([[gnu::used]]) inline void FuncName(Type inst) noexcept { \
5152
::mlib::delete_unique(inst); \
52-
} static_assert(true, "")) /* */ \
53-
(void FuncName(Type inst))
53+
}) \
54+
/*-
55+
* If C, just declares the function signature, which will be defined in some C++ translation
56+
* unit.
57+
*/ \
58+
(void FuncName(Type inst);) \
59+
/* Trailing static-assert to force a semicolon */\
60+
mlib_static_assert(true, "")
61+
// clang-format on
5462

5563
#if mlib_is_cxx()
5664

src/amongoc/nano/util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct deferred_conversion {
2121
mlib::object_t<F> _func;
2222

2323
// Need to use std::invoke_result for MSVC bugs, not mlib::invoke_result
24-
constexpr operator std::invoke_result_t<F>() { return std::invoke(static_cast<F&&>(_func)); }
24+
constexpr operator std::invoke_result_t<F>() { return mlib::invoke(static_cast<F&&>(_func)); }
2525

2626
constexpr operator std::invoke_result_t<const F>() const {
2727
return mlib::invoke(static_cast<F const&&>(_func));

0 commit comments

Comments
 (0)