Boost logo

Boost :

From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-07-03 20:17:01


In general noone would write a function that took an int by const
reference because doing so doesn't make sense from a performance
standpoint. However often times we pass these trivial types to functions
generically written to take const T&.

It seems like type traits would make it simple to overload based on this
convention. However I don't see a type trait that is fit for this use case.

The has_trivial_copy trait would seem promising but it could return true
for large pod objects that you wouldn't want to copy.

The is_scalar trait seems promising but it will return false for
lightweight user defined types and be suboptimal.

Using has_trivial_copy together with some sizeof limit seems promising
but a bit hand wavy.

Is there a trait designed for this use case I'm overlooking?

Thanks,

Michael Marcin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk