goodbye
parent
700c9873a8
commit
c8dbaef7d3
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(blt-gp VERSION 0.0.23)
|
||||
project(blt-gp VERSION 0.0.24)
|
||||
|
||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||
|
|
|
@ -296,17 +296,23 @@ void test()
|
|||
blt::gp::type_system type_system;
|
||||
blt::gp::gp_program program(type_system);
|
||||
|
||||
blt::gp::operation_t add = blt::gp::make_operator([](float a, float b) { return a + b; });
|
||||
blt::gp::operation_t<float(float, float)> sub([](float a, float b) { return a - b; });
|
||||
blt::gp::operation_t<float(float, float)> mul([](float a, float b) { return a * b; });
|
||||
blt::gp::operation_t<float(float, float)> pro_div([](float a, float b) { return b == 0 ? 0.0f : a / b; });
|
||||
blt::gp::operation_t<float()> lit([]() {return 0.0f;});
|
||||
blt::gp::operation_t add([](float a, float b) { return a + b; });
|
||||
blt::gp::operation_t sub([](float a, float b) { return a - b; });
|
||||
blt::gp::operation_t mul([](float a, float b) { return a * b; });
|
||||
blt::gp::operation_t pro_div([](float a, float b) { return b == 0 ? 0.0f : a / b; });
|
||||
blt::gp::operation_t lit([]() { return 0.0f; });
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
type_system.register_type<float>();
|
||||
type_system.register_type<bool>();
|
||||
|
||||
program.add_operator(add);
|
||||
program.add_operator(sub);
|
||||
program.add_operator(mul);
|
||||
program.add_operator(pro_div);
|
||||
program.add_operator(lit);
|
||||
|
||||
// constexpr blt::size_t MAX_ALIGNMENT = 8;
|
||||
// test();
|
||||
|
|
|
@ -99,13 +99,6 @@ namespace blt::gp
|
|||
std::string name_{};
|
||||
};
|
||||
|
||||
class allowed_types_t
|
||||
{
|
||||
public:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
class type_system
|
||||
{
|
||||
public:
|
||||
|
@ -163,6 +156,8 @@ namespace blt::gp
|
|||
|
||||
[[nodiscard]] constexpr inline Return operator()(stack_allocator& allocator) const
|
||||
{
|
||||
if constexpr (sizeof...(Args) == 0)
|
||||
return func();
|
||||
constexpr auto seq = std::make_integer_sequence<blt::u64, sizeof...(Args)>();
|
||||
Return ret = exec_sequence_to_indices(allocator, seq);
|
||||
allocator.call_destructors<Args...>();
|
||||
|
@ -186,23 +181,30 @@ namespace blt::gp
|
|||
function_t func;
|
||||
};
|
||||
|
||||
template<typename Return, typename Class, typename... Args>
|
||||
class operation_t<Return (Class::*)(Args...) const> : public operation_t<Return(Args...)>
|
||||
{
|
||||
public:
|
||||
using operation_t<Return(Args...)>::operation_t;
|
||||
};
|
||||
|
||||
template<typename Lambda>
|
||||
operation_t(Lambda) -> operation_t<decltype(&Lambda::operator())>;
|
||||
|
||||
template<typename Return, typename... Args>
|
||||
operation_t(Return (*)(Args...)) -> operation_t<Return(Args...)>;
|
||||
|
||||
template<typename Return, typename Class, typename... Args>
|
||||
operation_t(Return (Class::*)(Args...) const) -> operation_t<Return(Args...)>;
|
||||
|
||||
template<typename Return, typename Class, typename... Args>
|
||||
operation_t<Return(Args...)> make_operator(Return (Class::*)(Args...) const lambda)
|
||||
{
|
||||
// https://ventspace.wordpress.com/2022/04/11/quick-snippet-c-type-trait-templates-for-lambda-details/
|
||||
}
|
||||
|
||||
template<typename Lambda>
|
||||
operation_t<decltype(&Lambda::operator())> make_operator(Lambda&& lambda)
|
||||
{
|
||||
return operation_t<decltype(&Lambda::operator())>(std::forward(lambda));
|
||||
}
|
||||
// templat\e<typename Return, typename Class, typename... Args>
|
||||
// operation_t<Return(Args...)> make_operator(Return (Class::*)(Args...) const lambda)
|
||||
// {
|
||||
// // https://ventspace.wordpress.com/2022/04/11/quick-snippet-c-type-trait-templates-for-lambda-details/
|
||||
// }
|
||||
//
|
||||
// template<typename Lambda>
|
||||
// operation_t<decltype(&Lambda::operator())> make_operator(Lambda&& lambda)
|
||||
// {
|
||||
// return operation_t<decltype(&Lambda::operator())>(std::forward(lambda));
|
||||
// }
|
||||
//
|
||||
// template<typename Return, typename... Args>
|
||||
// operation(std::function<Return(Args...)>) -> operation<Return(Args...)>;
|
||||
|
|
Loading…
Reference in New Issue