trying weird lambda CTAD

thread
Brett 2024-06-19 22:08:10 -04:00
parent bfd70c7f81
commit 700c9873a8
3 changed files with 17 additions and 5 deletions

View File

@ -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)

View File

@ -296,7 +296,7 @@ void test()
blt::gp::type_system type_system;
blt::gp::gp_program program(type_system);
blt::gp::operation_t<float(float, float)> 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<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; });

View File

@ -188,9 +188,21 @@ namespace blt::gp
template<typename Return, typename... Args>
operation_t(Return (*)(Args...)) -> operation_t<Return(Args...)>;
//
// template<typename Sig>
// operation(std::function<Sig>) -> operation<Sig>;
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));
}
//
// template<typename Return, typename... Args>
// operation(std::function<Return(Args...)>) -> operation<Return(Args...)>;