Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/aether-miscpp/meta/function_signature.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@
#include "aether-miscpp/meta/type_list.h"

namespace ae {
template <typename Signature>
struct FunctionSignatureTraits;

template <typename Ret, typename... Args>
struct FunctionSignatureImpl {
struct FunctionSignatureTraits<Ret(Args...)> {
using ret = Ret;
using args = TypeList<Args...>;
using signature = ret(args, ...);
using func_ptr = ret (*)(args, ...);
};

template <typename R, typename... Args>
auto GetFunctionSignature(R (*)(Args...)) -> FunctionSignatureImpl<R, Args...>;
auto GetFunctionSignature(R (*)(Args...))
-> FunctionSignatureTraits<R(Args...)>;

template <typename R, typename C, typename... Args>
auto GetFunctionSignature(R (C::*)(Args...))
-> FunctionSignatureImpl<R, Args...>;
-> FunctionSignatureTraits<R(Args...)>;

template <typename R, typename C, typename... Args>
auto GetFunctionSignature(R (C::*)(Args...) const)
-> FunctionSignatureImpl<R, Args...>;
-> FunctionSignatureTraits<R(Args...)>;

template <typename Callable>
auto GetFunctionSignature(Callable)
Expand Down
14 changes: 11 additions & 3 deletions src/aether-miscpp/types/small_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ template <typename TCallable, typename TSource, typename TRet,
* conversion.
*/
concept CompatibleCallable =
std::constructible_from<TCallable, TSource> &&
std::is_nothrow_constructible_v<TCallable, TSource> &&
std::is_nothrow_move_constructible_v<TCallable> &&
std::invocable<TCallable&, TArgs&&...> &&
(std::is_void_v<TRet> ||
std::is_convertible_v<std::invoke_result_t<TCallable&, TArgs&&...>, TRet>);
Expand Down Expand Up @@ -154,6 +151,11 @@ class SmallFunction<TRet(TArgs...), Size, Alignment> {
"SmallFunction target size exceeds storage size");
static_assert(alignof(Type) <= Alignment,
"SmallFunction target alignment exceeds storage alignment");
static_assert(std::constructible_from<Type, TFunctor> &&
std::is_nothrow_constructible_v<Type, TFunctor> &&
std::is_nothrow_move_constructible_v<Type>,
"TFunctor must meet specific construction constraints");

new (storage_.data()) Type{std::forward<TFunctor>(functor)};
}

Expand All @@ -175,6 +177,12 @@ class SmallFunction<TRet(TArgs...), Size, Alignment> {
static_assert(
alignof(Type) <= Alignment,
"SmallFunction MethodPtr target alignment exceeds storage alignment");

static_assert(std::constructible_from<Type, MPtr> &&
std::is_nothrow_constructible_v<Type, MPtr> &&
std::is_nothrow_move_constructible_v<Type>,
"MPtr must meet specific construction constraints");

new (storage_.data()) Type{std::forward<MPtr>(method_ptr)};
}

Expand Down
Loading