lundi 29 août 2022

std::alignment_union for a lambda expression

This is a follow up question to : this question - replacing an std::function with none allocating one , that does not use std .

Was wondering if there is something more robust that can replace: std::aligned_union

 typedef unsigned char callable_array[100];
 typename std::aligned_union<0, callable_array, CallableT<void(*)()>, CallableT<void (CallableT<void(*)()>::*)()>>::type callable_;
                                        

The suggested code to do that is causing an compilation error: link

CallableT<decltype([]()->void {})>, // error: lambda expression in an unevaluated operand

trying both c++11 and c++14

It also uses std::max - was hoping for some ideas on how to replace it as well.

Aucun commentaire:

Enregistrer un commentaire