diff --git a/src-test/common/AnyFnTest.cpp b/src-test/common/AnyFnTest.cpp new file mode 100644 index 0000000000..960e765c0c --- /dev/null +++ b/src-test/common/AnyFnTest.cpp @@ -0,0 +1,24 @@ +#include "ll/core/LeviLamina.h" + +#include "ll/api/data/AnyFunction.h" + +static bool run = [] { + using ll::data::AnyFunction; + + + auto fn = AnyFunction([](std::string const& par, int i, std::vector&& fs) { + ll::getLogger().warn("{}, {}, {}", par, i, fs); + }); + + fn(std::string{"emmmmm"}, 10, std::vector{0.2f, 0.2f, 0.2f}); + + auto vec = std::vector{0.7f, 0.7f, 0.7f}; + + fn = AnyFunction([](std::string const& par, int i, std::vector&& fs) { + ll::getLogger().info("{} | {} | {}", par, i, fs); + }); + + fn(std::string{"hmmmmm"}, 17, std::ref(vec)); + + return true; +}(); diff --git a/src/ll/api/base/Concepts.h b/src/ll/api/base/Concepts.h index 54efa90217..ff0ee2bd62 100644 --- a/src/ll/api/base/Concepts.h +++ b/src/ll/api/base/Concepts.h @@ -2,56 +2,28 @@ #include #include -#include #include #include "ll/api/base/Macro.h" #include "ll/api/base/StdInt.h" +#include "ll/api/base/TypeTraits.h" namespace ll::concepts { template -struct is_in_types; - -template class U, class... Ts> -struct is_in_types> : std::bool_constant<(std::is_same_v || ...)> {}; - -template -inline constexpr bool is_in_types_v = is_in_types::value; - -template -concept IsInTypes = is_in_types_v; - -template -inline constexpr bool is_one_of_v = (std::is_same_v || ...); - -template -struct is_one_of : std::bool_constant> {}; +concept IsInTypes = traits::is_in_types_v; template -concept IsOneOf = is_one_of_v; +concept IsOneOf = traits::is_one_of_v; template -inline constexpr bool is_all_same_v = (std::is_same_v && ...); - -template -struct is_all_same : std::bool_constant> {}; - -template -concept IsAllSame = is_all_same_v; - -template -inline constexpr bool is_string_v = std::is_constructible_v; - -template -inline constexpr bool is_non_char_integral_v = - is_one_of_v, bool, schar, uchar, short, ushort, int, uint, long, ulong, int64, uint64>; +concept IsAllSame = traits::is_all_same_v; template -concept IsNonCharIntegral = is_non_char_integral_v; +concept IsNonCharIntegral = traits::is_non_char_integral_v; template -concept IsString = is_string_v; +concept IsString = traits::is_string_v; template class Z> concept Require = Z::value; @@ -100,32 +72,12 @@ template concept IsVectorBase = std::is_base_of_v; template class Z> -inline constexpr bool is_specialization_of_v = false; - -template