Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-11-29 16:15:22


At 10:43 AM 11/29/99 -0500, Howard Hinnant wrote:

>I've been exploring uses of call_traits for something like:
>
>template <typename Iterator>
>bool
>foo(Iterator i, call_traits<Iterator>::type j)
>{
> // do something...
>}
>
>I've been plugging in both small and large iterators using both pass
by
>value and pass by reference and studing the resulting assembly
>(optimizations on).
>
> ...
>
>No significant difference.
>
>So I'm now looking for an example where pass by (const) value (for a

>small and fast type) is demonstrably superior to pass by const
reference.

I ran into a compiler (Borland?) once that would do more optimization
if the declaration said "inline void f( int const t )" rather than
"inline void f( int t )". It knew t was never modified, so it never
copied it.

For that compiler, John's idea of adding const would be an
optimization in addition to being safer.

But your other message is correct; there are motivations beyond
optimization for call_traits<>.

--Beman


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