Jon Stewart on 18 Jul 2003 17:19:01 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
[ALACPP] oh, the tragedy |
Ah, COM. So, I'm starting to wrap the ol' VARIANT datatype. class VarWrapperClass { VARIANT& Var; VarWrapperClass& operator=(bool val) { Var.vt = VT_BOOL; Var.boolVal = val; return *this; } operator const bool*() const { if(VT_BOOL == Var.vt) { return reinterpret_cast<const bool*>(Var.pBoolVal); } return 0; } } It mixes the hell out of semantics, but I don't care. I'll have do so much VARIANT conversion that any kind of convenient shorthand is worth it. So... I've got an if-statement that looks like this: if(somePtr && 1 == somePtr->Count && (const bool* val = VarWrapperClass(somePtr->Array[0]))) { SetSomeBool(*val); } It will not compile. This if-statement will, however: if(const bool* val = VarWrapperClass(somePtr->Array[0])) { SetSomeBool(*val); } The compiler simply gets confused by the creation and conversion in the compound if expression. Compiling is such sweet sorrow. <sigh> Jon -- Jon Stewart stew1@xxxxxxxxxxx _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp