Boost logo

Boost Users :

From: Sohail Somani (s.somani_at_[hidden])
Date: 2006-10-24 19:58:47


> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Peng Yu
> Subject: [Boost-users] Does shared_array's get() method
> introduce runtimeoverhead?
>
> Hi,
>
> I have the following two code segments. I'm wondering if there is any
> run time overhead of the get() method. Shall I use the latter one
> instead of the former one?
>
>
>
> boost::shared_array a(new int[100]);
> for(int i = 0; i < 100; ++ i)
> a[i] = i;
>
>
>
> boost::shared_array a(new int[100]);
> int a_ptr = a.get();
> for(int i = 0; i < 100; ++ i)
> a_ptr[i] = i;

I'd guess not (from shared_array.hpp):

template<class T> class shared_array
{
...
    T * get() const // never throws
    {
        return px;
    }
...

Unless that doesn't get inlined of course.

PS: Use the source :)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net