Empty Class

Mar 4, 2009 at 10:23am
Hi all

i want to know where we can use empty classes?

or what is use of empty class ?

can any one provide some information (example also if possible)

Thanks in advance , sorry for bad english.
Last edited on Mar 4, 2009 at 10:24am
Mar 4, 2009 at 10:38am
Classes are distinct types. An empty class can be used in an intermediate step to force an overload, template instantiation or compile time constant value.

It's never normally used on its own.
Mar 4, 2009 at 5:46pm
They can be used to differentiate between states (see boost::statechart) or execptions that do not require any member data. I'm sure there are other uses, as well, but these are the first that come to mind right now.

Oh! An even better example would be iterator_traits and the empty "tag" classes that are used to differentiate types of iterators passed as template arguments.
Topic archived. No new replies allowed.