diff --git a/octa/functional.h b/octa/functional.h index 4c49920..ce0aba8 100644 --- a/octa/functional.h +++ b/octa/functional.h @@ -366,11 +366,21 @@ namespace detail { template A &get_alloc() { - return (A &)manager; + union { + const FunctionManager **m; + A *alloc; + } u; + u.m = &manager; + return *u.alloc; } template const A &get_alloc() const { - return (const A &)manager; + union { + const FunctionManager * const *m; + const A *alloc; + } u; + u.m = &manager; + return *u.alloc; } }; @@ -394,7 +404,12 @@ namespace detail { } static T &get_ref(const FmStorage &s) { - return (T &)(s.data); + union { + const FunctorData *data; + T *ret; + } u; + u.data = &s.data; + return *u.ret; } }; @@ -741,7 +756,7 @@ namespace detail { template struct DcLambdaTypes { - typedef R (*Ptr)(A...); + typedef octa::Function Ptr; typedef octa::Function Obj; };