DBG bool

DBG would be slightly cooler if bools wouldn’t have to be casted to int

1 Like

are you hoping for some kind of implicit conversion from true to "true" ?

a String(bool) constructor, so to speak.

You can just do DBG( "some text: " << (boolExpr ? "true" : "false") );

3 Likes

no, it would be enough if it showed 0 and 1. and i know how to cast, but i felt like it would be a minor improvement, making statements a bit shorter sometimes

edit:

bool someState;
bool someOtherState;
float someParameter;
float someOtherParameter;

DBG(someState << ", " << someOtherState << ", " << someParameter << ", " << someOtherParameter);

lines like this are long enough even without the need to cast stuff

1 Like

ok then. if it breaks too many other things let’s just keep it like this :slight_smile: thanks for the explanation

I’m no expert on macros, but if we can’t overload the String(bool) constructor, wouldn’t it be possible to overload the DBG function instead so that there is a second version to accept bools? It’s frustrating having to type out DBG( "some text: " << (boolExpr ? "true" : "false") ); every time.

I don’t think you can overload macros and DBG is a macro iirc, but why not just create a simple macro that does what you have to keep typing if it’s a pain?

#define DBOOL(V) (V ? "true" : "false")

Job done :slight_smile:

5 Likes