more types

main
Brett 2025-04-21 13:12:22 -04:00
parent 7e68950a16
commit 8d3a088049
3 changed files with 50 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 5.4.3) set(BLT_VERSION 5.4.4)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -58,6 +58,54 @@ namespace blt
template <typename... Ts> template <typename... Ts>
using filter_void_t = typename filter_void<Ts...>::type; using filter_void_t = typename filter_void<Ts...>::type;
template <typename Type, typename Func>
struct member_func_meta
{
using can_invoke = std::is_invocable<Func, Type>;
using return_type = std::conditional_t<can_invoke::value, std::invoke_result_t<Func, Type>, void>;
};
template <typename T, typename Func>
struct passthrough_value
{
using type = T;
using func = Func;
bool has_value = false;
explicit passthrough_value(const bool has_value): has_value(has_value)
{
}
explicit operator bool() const
{
return has_value;
}
};
template <typename Type, typename... Funcs>
struct first_invoke_member_func
{
constexpr static auto find_func()
{
return (... || []()
{
using Meta = member_func_meta<Type, Funcs>;
if constexpr (Meta::can_invoke::value)
{
return passthrough_value<typename Meta::return_type, Funcs>{true};
}
return passthrough_value<void, Funcs>{false};
}());
}
using result = decltype(find_func());
using return_type = typename result::type;
using func_type = typename result::func;
};
template <typename Type, typename... Args> template <typename Type, typename... Args>
struct member_func_detail; struct member_func_detail;

@ -1 +1 @@
Subproject commit 154c63489e84d5569d3b466342a2ae8fd99e4734 Subproject commit 8a889d3699b3c09ade435641fb034427f3fd12b6