[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Bug with macros
|
On 27/12/13 04:20, Alec Teal wrote:
Hey guys,
This example was taken from a program, I've distilled it to it's
essence though but chosen to keep an example because it expresses a
time where one might use this (I find all to often bugs can be given a
low priority simply because they are rarely used).
Anyway:
------------------------------------------------------
#define CREATE_LISTENER(FOR,TYPE) \
class On##FOR##Emmitter; \
class On##FOR##Listener { \
private: \
void stopListeningTo(On##FOR##Emitter* what) { } \
On##FOR##Emitter* listeningTo; \
protected:\
On##FOR##Listener() { listeningTo = nullptr; } \
virtual ~On##FOR##Listener() { if(listeningTo != nullptr) {
stopListeningTo(listeningTo); } } \
#define FINISH_LISTENER() };
class Number { };
CREATE_LISTENER(ValueChange,Number)
FINISH_LISTENER()
------------------------------------------------------
[snip]
Alec
I must apologise there is a typo in the above, a double m in the first
"Emitter" it should read:
---------------------------------------------------------
#define CREATE_LISTENER(FOR,TYPE) \
class On##FOR##Emitter; \
class On##FOR##Listener { \
private: \
void stopListeningTo(On##FOR##Emitter*) { } \
On##FOR##Emitter* listeningTo; \
protected:\
On##FOR##Listener() { listeningTo = nullptr; } \
virtual ~On##FOR##Listener() { if(listeningTo != nullptr) {
stopListeningTo(listeningTo); } } \
#define FINISH_LISTENER() };
class Number { };
CREATE_LISTENER(ValueChange,Number)
FINISH_LISTENER()
---------------------------------------------------------
I am very sorry, I'm not sure how it happened, I've lost the error I was
trying to isolate anyway so please dis(card|regard) this message. I feel
most silly!
Alec