My general rule is to pass by value for primitive types and pass by reference for objects (obviously const'd if need be). However, I'm not sure what route to take with enumerated types. I'd assume that pass by value is preferred since they are seemingly small, but I'd like to hear others thoughts.
+13
A:
No other thoughts. An enum is just an integral value in a fancy dress (or suit, if you prefer). It has no internal structure and will travel in a register given a chance. If you'd pass an int by value, pass an enum that way, too.
bmargulies
2009-11-15 20:17:24
`3.9.1/7`: "A synonym for integral type is integer type."
Johannes Schaub - litb
2009-11-16 04:10:30
+2
A:
Enum have a underlying representation type which is an integer types. There are no more reasons (and no less) to pass them by reference that there are reasons to pass integer types by reference.
AProgrammer
2009-11-15 20:18:14
Instead of posting this as an ansqwer, it is better suited to be posted as a comment.
Ramon Zarazua
2009-11-16 09:50:04