Originally Posted by
iMalc
Bug here:
Code:
TT CThreadClassType<T>::CThreadClassType(CClassType& Data)
{
InitializeCriticalSection(&m_Sync); // BUG!!!!
EnterCriticalSection(&m_Sync);
m_bLogging = Data.m_bLogging;
m_Data = Data.m_Data;
LeaveCriticalSection(&m_Sync);
}
Bug? How do you figure? It's a constructor, so it needs to initialize the critical section.
Originally Posted by
iMalc
I would perfer the two parameter friend function version of operators like binary + so that both sides are implicitly convertable.
You mean such as
Code:
operator + (T, const CDataType<T>& )
I think?
Originally Posted by
iMalc
Spelling mistake: MinEqualThenData.
Actually, why do you give the parameter a different name each time? Why not just pick something like rhs and use that for all of them. Seems to me it would make your life a lot easier.
Actually, no, it's not a mistake. There is a word "then" and there is a word "than". If this equals that, then do this. If this is less than that, do this.
Dunno. I just find making a little descriptive names better. Anyway, I changed them all to "Data" instead.
Originally Posted by
iMalc
You're missing unary operator +.
Originally Posted by
iMalc
If you want to prevent copying then your copy constructor and copy assignment operator need to take const references.
Originally Posted by
iMalc
Operator << should take Data as a const reference.
Missed those.
Uploaded new files with more fixes.
UPDATE: Proper include guard.
Got rid of macros.
UPDATE2:
Re-ordered operators a little.
Added global operators. All tests pass!
Yes, even this:
Code:
MyInt = MyInt + MyInt - MyInt * MyInt / MyInt
% MyInt & MyInt << MyInt >> MyInt ^ MyInt
| MyInt %= MyInt &= MyInt *= MyInt += MyInt
-= MyInt /= MyInt <<= MyInt >>= MyInt ^= MyInt
|= MyInt;