Информация об изменениях

Сообщение Re[2]: Получить сигнатуру из ламбды от 12.08.2020 18:27

Изменено 12.08.2020 18:29 Barbar1an

Re[2]: Получить сигнатуру из ламбды
Здравствуйте, YuriV, Вы писали:

вот так хочу заюзать

    template<class ...A> struct CActiveDelegateAAA
    {
        CDelegate<void(A...)>        Function;
        std::function<void(A...)>    Lambda;
        EListen                Listen;

        CActiveDelegateAAA()
        {
        }
    };

    template<class X, class Y, typename...A> CActiveDelegateAAA<A...> CreateActiveDelegate(Y* x, void (X::*func)(A...), EListen l)
    { 
        CActiveDelegateAAA<A...> d;
        d.Function = CDelegate<void(A...)>(x, func);
        d.Listen = l;
        return d;
    }


    template<class ...L> CActiveDelegateAAA<typename fn::traits<L>::args> CreateLambdaDelegate(L la, EListen l)
    { 
        CActiveDelegateAAA<typename fn::traits<L>::args> d;
        d.Lambda = la;
        d.Listen = l;
        return d;
    }

    #define FunctionSubscriber(method, l)    CreateActiveDelegate(this, &std::remove_pointer<decltype(this)>::type::method, l)
    #define LambdaSubscriber(la, l)        CreateLambdaDelegate(la, l)

    template<class ...A> class CActiveEventAAA
    {
        public:
            void operator += (CActiveDelegateAAA<A...> & d)
            {
                Subscribers.push_back(d);
            }

        protected:
            CArray<CActiveDelegateAAA<A...>>    Subscribers;
    };


    class A
    {
        void AAA(CString &)
        {
            CActiveEventAAA<CString &> aaa;

            aaa += FunctionSubscriber(AAA, EListen::NormalAll);
            aaa += LambdaSubscriber([](CString &){}, EListen::NormalAll);

        }
    };
Re[2]: Получить сигнатуру из ламбды
Здравствуйте, YuriV, Вы писали:

вот так хочу заюзать

    template<class ...A> struct CActiveDelegate
    {
        CDelegate<void(A...)>        Function;
        std::function<void(A...)>    Lambda;
        EListen                Listen;

        CActiveDelegate()
        {
        }
    };

    template<class X, class Y, typename...A> CActiveDelegate<A...> CreateActiveDelegate(Y* x, void (X::*func)(A...), EListen l)
    { 
        CActiveDelegate<A...> d;
        d.Function = fastdelegate<void(A...)>(x, func);
        d.Listen = l;
        return d;
    }


    template<class ...L> CActiveDelegate<typename fn::traits<L>::args> CreateLambdaDelegate(L la, EListen l)
    { 
        CActiveDelegate<typename fn::traits<L>::args> d;
        d.Lambda = la;
        d.Listen = l;
        return d;
    }

    #define FunctionSubscriber(method, l)    CreateActiveDelegate(this, &std::remove_pointer<decltype(this)>::type::method, l)
    #define LambdaSubscriber(la, l)        CreateLambdaDelegate(la, l)

    template<class ...A> class CActiveEvent
    {
        public:
            void operator += (CActiveDelegate<A...> & d)
            {
                Subscribers.push_back(d);
            }

        protected:
            CArray<CActiveDelegate<A...>>    Subscribers;
    };


    class A
    {
        void AAA(CString &)
        {
            CActiveEvent<CString &> aaa;

            aaa += FunctionSubscriber(AAA, EListen::NormalAll);
            aaa += LambdaSubscriber([](CString &){}, EListen::NormalAll);

        }
    };