Tvoid? tCIDLib?

I am not much of a c++ programmer, but I am reading http://www.edm2.com/0405/enumeration.html.  Here we have some code from that article:

      



// A macro to generate the standard enum functions
#define StdEnumTricks(eEnumType) \
inline void operator++(eEnumType& eVal) \
{ \
    eVal = eEnumType(eVal+1); \
} \
\
inline void operator++(eEnumType& eVal, int)  \
{ \
    eVal = eEnumType(eVal+1); \
} \
\
inline void operator--(eEnumType& eVal) \
{ \
    eVal = eEnumType(eVal-1); \
} \
\
inline tCIDLib::TVoid operator--(eEnumType& eVal, int)  \
{ \
    eVal = eEnumType(eVal-1); \
} \
\
inline eEnumType eEnumMax(eEnumType) \
{ \
    return eEnumType##_Max; \
} \
\
inline eEnumType eEnumMin(eEnumType) \
{ \
    return eEnumType##_Min; \


Notice the tCIDLIB::Tvoid.  

What is going on here?  What is TVoid used for?  Is the library reference portable?  I will be using gcc.
astar666Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrwad99Commented:
??!  That is completely new to me !

One thing is for sure, and that is that it is not part of the standard.  I think what has happened is that this is some custom type (I cannot find any mention of it on MSDN, so it is not MS specific) defined to help this code you are looking at.

Regarding portability, then I would not imagine that that would be an issue, since it is almost certainly something that is defined within the code that is using it.  

But nonetheless, this is interesting, and it will be cool to hear what the real gurus of C++ have to say on this...
0
Jaime OlivaresSoftware ArchitectCommented:
Hi astar666,
You can be sure nor Tvoid nor tCIDLib are part of any C++ standard, so there are user-defined class and member.


Good luck,
Jaime.
0
jkrCommented:
Check out the other files - I am pretty sure that somewhere there is a

typedef void TVoid;

The library seems to use it's own type for 'void', that's all. However, I cannot see any advantage here...
0
bcladdCommented:
(1) I don't remember tCIDLib from the OS/2 days (but it has been a while). Looking at the original source, it looks like an editing error (the other return types look like they, too, could have that return type but were edited to the standard void type).

(2) I, personally, don't like the void return type for the increment/decrement operators. Though it might be evil, it is possible to use increment operators inside of other, larger expressions. Consider an array indexed by daysOfTheWeek:

while (theDay != eEnumMax(daysOfTheWeek)) {
  cout << stuff[theDay++] << endl;
}

This would not work with the given macro. Might make more sense to edit it to
// A macro to generate the standard enum functions
#define StdEnumTricks(eEnumType) \
inline eEnumType operator++(eEnumType& eVal) \
{ \
    eVal = eEnumType(eVal+1); \
    return eVal; \
} \
\
inline eEnumType operator++(eEnumType& eVal, int)  \
{ \
    eEnumType eTemp = eVal; \
    eVal = eEnumType(eVal+1); \
    return eTemp; \
} \
\
inline eEnumType operator--(eEnumType& eVal) \
{ \
    eVal = eEnumType(eVal-1); \
    return eVal; \
} \
\
inline eEnumType operator--(eEnumType& eVal, int)  \
{ \
    eEnumType eTemp = eVal; \
    eVal = eEnumType(eVal-1); \
    return eTemp; \
} \
\
inline eEnumType eEnumMax(eEnumType) \
{ \
    return eEnumType##_Max; \
} \
\
inline eEnumType eEnumMin(eEnumType) \
{ \
    return eEnumType##_Min; \
}

This way you return a pre or post incremented (decremented) value from the operator which is much more what is expected.

-bcl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.