Publish an efficient and practical C ++ delegation Qlib :: Event

xiaoxiao2021-03-05  25

Publish an efficient practical C delegation

Download address http://upload.programfan.com/upfile/200548160qevent.rar

A simple and efficient C delegate, support the general function, imitation function, and the delegation of the class member function, and declare an arbitrary commission of 0-9 parameters in the same way.

A support compiler and performance support VC6.0 and VC7.1 performance are the same as Boost :: Function library. Use [] (...) to call a single function to delegate performance.

The second declaration is currently supporting 0 to 9 parameters QLIB :: Event EV0; // Zero parameter Qlib :: Event EV1; // A parameter Qlib :: Event EV3; // Three parameters

Trifixed function Qlib :: Event EV2; Qlib :: Event EV1 (& test1); Qlib :: Event EV1 ((Hello ())); // vc60 Directly use EV1 (Hello ()), VC70 requires EV1 ((Hello ())) QLIB :: Event EV1 (& H, & Hello :: Test1); Qlib :: Event EV1 (EV2); QLIB :: Event EV1 (EV2 [0]);

Four function binding supports normal functions, imitation functions, class member functions, the same type entrustment and element EV1.BIND (& Test1); Ev1.bind (Hello ()); Ev1.bind (& H, & Hello :: test1) ; // Compatible form EV1 = & test1; EV1 = Hello (); ev1 qlib :: Event (& Hello :: test1); // Support the same type of commissioned EV1 = EV2; EV1 = EV2 [0];

5 Judgment Binding Functions Number i = Ev1.hasbind (& Test1); i = ev1.hasbind (Hello ()); i = ev1.hasbind (& H, & Hello :: Test1);

Six Function Solutions Ev1.unbind (& Test1); ev1.unbind (Hello ()); Ev1.unbind (& H, & Hello :: Test1); // Compatible Form EV1 - = & test1; ev1 - = hello (); ev1 - = Qlib :: Event (& H, & Hello :: Test1); // Support the same type of commission EV1 - = EV2; EV1 - = EV2 [0];

Seven judging whether the equal EV1 == EV2; EV1! = EV2 [0]; // For a single function of the delegation EV1 == & Tes1; EV1 == Hello (); ev1 == Qlib :: Event (& H & Hello :: test1);

Eight removal elements ev1.removesame ();

Nine-auxiliary function parameters number INT i = ev1.Param; whether it is empty BOOL B = ev1.empty (); element number int size = ev1.size (); exchange EV1.SWAP (EV2);

Ten function call form // Direct calls EV1 (10); // single member mode call for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-38212.html

New Post(0)