[Development] A modest proposal: disable lower-case keywords (emit, foreach, forever, signals, slots) by default

Ville Voutilainen ville.voutilainen at gmail.com
Wed Feb 26 00:59:26 CET 2020


On Tue, 25 Feb 2020 at 10:19, Ville Voutilainen
<ville.voutilainen at gmail.com> wrote:
> Or perhaps qEmit(this)->my_signal(Args...);
>
> and hide the befriending of qEmit (so that private/protected don't

This doesn't even need friending.

#include <iostream>

template <class T>
struct qEmit
{
    T* that;
    qEmit(T* it) : that(it) {}
    T* operator->() {return that;}
};

struct X
{
    void sig1() {std::cout << "sig1\n";}
    void sig2() {std::cout << "sig2\n";}
    void foo() {
        qEmit(this)->sig1();
        qEmit(this)->sig2();
    }
};

int main()
{
    X x;
    x.foo();
}


More information about the Development mailing list