On Fri, Feb 25, 2011 at 11:33:58AM -0800, Andrew Pinski wrote: > On Fri, Feb 25, 2011 at 11:21 AM, Kyle Girard <k...@kdmanalytics.com> wrote: > > > >> That *is* the content of the bar method. What exactly do you expect to > >> see > >> happening when you assign a class with no members? There's nothing to do! > > > > > > I was hoping to see the assignment. My example might have been a little > > too simple. Here's a slightly more complex example: > > > > foo.hh > > > > class A > > { > > public: > > void yay(){}; > > }; > > A is still an empty class, try adding "int a;" and you will see some code > there.
The fact that passing an empty class has zero cost is used quite a bit in the design of the standard library to generate efficient specialized templates. The empty objects are just used to select the correct overloaded form.