From 91dd2f03b53f0f7194ac99a681d4f44977ab256e Mon Sep 17 00:00:00 2001 From: Kim-J-Smith <3440910457@qq.com> Date: Thu, 28 May 2026 01:10:20 +0800 Subject: [PATCH 1/9] docs: update the version number and clear release notes. --- CMakeLists.txt | 2 +- README.md | 2 +- docs/release/release_notes.md | 12 ++++-------- include/embed/embed_function.hpp | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f0c2ac..dcabe28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14) -project(embedded_function VERSION 2.1.5 LANGUAGES CXX) +project(embedded_function VERSION 2.1.6 LANGUAGES CXX) add_library(embedded_function INTERFACE) add_library(embedded_function::functions ALIAS embedded_function) set_target_properties(embedded_function PROPERTIES EXPORT_NAME functions) diff --git a/README.md b/README.md index fd0179d..4afb9dd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Embedded Function

- Version - 2.1.5 + Version - 2.1.6 License - MIT C++ - 11/14/17/20/23

diff --git a/docs/release/release_notes.md b/docs/release/release_notes.md index a39e4fa..7939c75 100644 --- a/docs/release/release_notes.md +++ b/docs/release/release_notes.md @@ -1,19 +1,15 @@ ## Fixed -- Fixed a bug where empty and trivial functor could be incorrectly treated as stateless. - -- Fixed MSVC 19.10–19.14 compatibility issue. +- ## Changed -- `fn_ref` now accepts temporary callable objects (previously disallowed rvalue references). - -- `basic_fn` no longer automatically aligns `BufferSize`. +- ## Added -- Added CTAD guides for `fn_ref` with `std::constant_wrapper`. +- ## Notes -- `std::constant_wrapper` support is experimental as of v2.1.5. +- `std::constant_wrapper` support is experimental as of v2.1.6. diff --git a/include/embed/embed_function.hpp b/include/embed/embed_function.hpp index f72432b..92db107 100644 --- a/include/embed/embed_function.hpp +++ b/include/embed/embed_function.hpp @@ -3,7 +3,7 @@ * * @date 2026-2-7 * - * @version 2.1.5 + * @version 2.1.6 * * @copyright Copyright (c) 2026 Kim-J-Smith * All rights reserved. From f894aab4fb97a9e0e14b5fff5b41ff1e025ddf90 Mon Sep 17 00:00:00 2001 From: Kim-J-Smith <3440910457@qq.com> Date: Thu, 28 May 2026 14:58:25 +0800 Subject: [PATCH 2/9] docs: update README.md and make_fn.md . --- README.md | 10 +-- docs/api/make_fn.md | 205 ++++++++++++++++++++++++++------------------ 2 files changed, 125 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 4afb9dd..91a68da 100644 --- a/README.md +++ b/README.md @@ -193,11 +193,11 @@ auto f = ebd::make_fn(Ambiguous_Callable_Object); ```cpp // Create specified function wrapper and automatically deduce the template arguments. -// The Callable_Object should be unambiguously callable (non-overload). -auto f = ebd::make_fn(Callable_Object); -auto f = ebd::make_fn(Callable_Object); -auto f = ebd::make_fn(Callable_Object); -auto f = ebd::make_fn(Callable_Object); +// The Callable_Object should be unambiguously callable (non-overload) if `Signature` is omitted. +auto f = ebd::make_fn(Callable_Object); +auto f = ebd::make_fn(Callable_Object); +auto f = ebd::make_fn(Callable_Object); +auto f = ebd::make_fn(Callable_Object); ``` ```cpp diff --git a/docs/api/make_fn.md b/docs/api/make_fn.md index aee405f..32d9796 100644 --- a/docs/api/make_fn.md +++ b/docs/api/make_fn.md @@ -2,152 +2,187 @@ ## Overview -`ebd::make_fn` is a factory function that creates function wrapper objects. It automatically deduces the signature and buffer size of the callable object, and returns an appropriate function wrapper (`ebd::fn` or `ebd::unique_fn`). +`ebd::make_fn` is a factory for creating Embedded Function wrappers from callable objects, function pointers, member pointers, and existing wrappers. + +It can: + +- deduce the signature of a lambda or other uniquely callable functor, +- choose `ebd::fn` or `ebd::unique_fn` automatically, +- build an empty wrapper with an explicit signature, +- create a wrapper with a specific wrapper type such as `ebd::safe_fn` or `ebd::fn_ref`. ## Overloads -### 1. Make function with specified signature for copyable functor +### 1. Copyable functor with explicit signature ```cpp -template -EMBED_NODISCARD inline fn -make_fn(Functor&& functor) noexcept; +template , + std::size_t BufferSize = sizeof(Class), + typename Fn = detail::conditional_t< + std::is_copy_constructible::value, + fn, + unique_fn>, + bool NoThrow = detail::is_nothrow_construct_from_functor::value> +EMBED_NODISCARD inline Fn make_fn(Functor&& functor) noexcept(NoThrow); ``` -Creates an `ebd::fn` with the specified signature for a copyable functor. +Creates a wrapper for a class-type callable when the signature is specified explicitly. For copyable functors, the resulting type is `ebd::fn`. -### 2. Make function with specified signature for move-only functor +### 2. Move-only functor with explicit signature ```cpp -template +template ::value> EMBED_NODISCARD inline unique_fn -make_fn(Functor&& functor) noexcept; +make_fn(Functor&& functor) noexcept(NoThrow); ``` -Creates an `ebd::unique_fn` with the specified signature for a move-only functor. +Creates an `ebd::unique_fn` for a move-only functor when the signature is specified explicitly. -### 3. Make an empty function with specified signature and buffer size +### 3. Empty wrapper with explicit signature ```cpp -template +template EMBED_NODISCARD inline fn make_fn(std::nullptr_t = nullptr) noexcept; ``` -Creates an empty `ebd::fn` with the specified signature and buffer size. +Creates an empty `ebd::fn` with the given signature and buffer size. -### 4. Make function for function pointer (auto deduce signature and buffer size) +### 4. Function pointer with deduced signature ```cpp template EMBED_NODISCARD inline fn -make_fn(Ret (*func_ptr) (Args...)) noexcept; +make_fn(Ret (*func_ptr)(Args...)) noexcept; ``` -Creates an `ebd::fn` from a function pointer, automatically deducing the signature and buffer size. +Creates an `ebd::fn` from a free-function pointer and deduces both signature and buffer size. -### 5. Make function for function pointer with specified signature +### 5. Function pointer with explicit signature ```cpp -template ::pure_sig*> +template ::pure_sig*> EMBED_NODISCARD inline fn make_fn(FunctionPtr func_ptr) noexcept; ``` -Creates an `ebd::fn` from a function pointer with the specified signature. +Creates an `ebd::fn` from a free-function pointer using the specified signature. -### 6. Create a function from another function (Copy) +### 6. Copy from another wrapper ```cpp template EMBED_NODISCARD inline detail::function -make_fn(const detail::function& fn) noexcept; +make_fn(const detail::function& fn) +noexcept(Cfg::isView || Cfg::assertNoThrow); ``` -Creates a function wrapper by copying another function wrapper. +Creates a wrapper by copying another `ebd::detail::function`. -### 7. Create a function from another function (Move) +### 7. Move from another wrapper ```cpp template EMBED_NODISCARD inline detail::function -make_fn(detail::function&& fn) noexcept; +make_fn(detail::function&& fn) +noexcept(Cfg::isView || Cfg::assertNoThrow); ``` -Creates a function wrapper by moving another function wrapper. +Creates a wrapper by moving another `ebd::detail::function`. -### 8. Make a function from lambda or unique-operator() functor +### 8. Lambda or uniquely callable functor ```cpp -template , +template , std::size_t BufferSize = sizeof(Class), typename Signature = detail::get_unique_signature_t, typename Fn = detail::conditional_t< std::is_copy_constructible::value, - fn, unique_fn - >> -EMBED_NODISCARD inline Fn make_fn(Lambda&& fn) noexcept; + fn, + unique_fn>, + bool NoThrow = detail::is_nothrow_construct_from_functor::value> +EMBED_NODISCARD inline Fn make_fn(Lambda&& fn) noexcept(NoThrow); ``` -Creates a function wrapper from a lambda or functor with a unique `operator()`, automatically deducing the signature and buffer size. +Creates a wrapper from a lambda or other functor with exactly one viable `operator()`. The signature is deduced automatically. -### 9. Make function for pointer to member function +### 9. Pointer to member function ```cpp template EMBED_NODISCARD inline auto make_fn(Ret(Class::* memfunc)(Args...) C V REF NOEXCEPT) noexcept --> fn, Args...) const, sizeof(memfunc)>; +-> fn< + Ret(detail::get_qualified_with_t, Args...) const, + sizeof(memfunc) + >; ``` -Creates an `ebd::fn` from a pointer to member function, automatically deducing the signature and buffer size. +Creates an `ebd::fn` from a pointer to member function. Cv/ref/noexcept qualifiers are preserved in the generated signature family. -### 10. Make function for member function pointer with specified signature +### 10. Member function pointer with explicit signature ```cpp -template , +template , std::size_t BufferSize = sizeof(MemFuncPtr)> EMBED_NODISCARD inline fn make_fn(MemFuncPtr memfunc_ptr) noexcept; ``` -Creates an `ebd::fn` from a member function pointer with the specified signature. +Creates an `ebd::fn` from a pointer to member function using the specified signature. -### 11. Make function for pointer to member object +### 11. Pointer to member object ```cpp -template +template ::type> EMBED_NODISCARD inline auto make_fn(T Class::* ptr_memobj) noexcept --> fn; +-> fn; ``` -Creates an `ebd::fn` from a pointer to member object. +Creates an `ebd::fn` that reads a member object from an instance. -### 12. In-place make function (C++17+) +### 12. In-place construction (C++17+) ```cpp template -EMBED_NODISCARD inline auto make_fn(std::in_place_type_t, CArgs&&... args) noexcept; +EMBED_NODISCARD inline auto +make_fn(std::in_place_type_t, CArgs&&... args) +noexcept(std::is_nothrow_constructible::value); template EMBED_NODISCARD inline auto -make_fn(std::in_place_type_t, std::initializer_list il, CArgs&&... args) noexcept; +make_fn(std::in_place_type_t, std::initializer_list il, CArgs&&... args) +noexcept(std::is_nothrow_constructible&, CArgs...>::value); ``` -Creates a function wrapper by in-place constructing the callable object within the internal buffer. +Constructs the callable directly inside the wrapper buffer. The returned wrapper type is deduced from the functor. -### 13. Make function with specified wrapper +### 13. Explicit wrapper type ```cpp -template