diff --git a/CMakeLists.txt b/CMakeLists.txt index a7b1de8..c769391 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.22) +project(blt-gp VERSION 0.0.23) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/examples/main.cpp b/examples/main.cpp index 4e2959b..1a8f61f 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -296,7 +296,7 @@ void test() blt::gp::type_system type_system; blt::gp::gp_program program(type_system); -blt::gp::operation_t add([](float a, float b) { return a + b; }); +blt::gp::operation_t add = blt::gp::make_operator([](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; }); diff --git a/include/blt/gp/program.h b/include/blt/gp/program.h index 3cf3a11..b549755 100644 --- a/include/blt/gp/program.h +++ b/include/blt/gp/program.h @@ -188,9 +188,21 @@ namespace blt::gp template operation_t(Return (*)(Args...)) -> operation_t; -// -// template -// operation(std::function) -> operation; + + template + operation_t(Return (Class::*)(Args...) const) -> operation_t; + + template + operation_t make_operator(Return (Class::*)(Args...) const lambda) + { + // https://ventspace.wordpress.com/2022/04/11/quick-snippet-c-type-trait-templates-for-lambda-details/ + } + + template + operation_t make_operator(Lambda&& lambda) + { + return operation_t(std::forward(lambda)); + } // // template // operation(std::function) -> operation;