Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2002-10-07 12:58:01

----- Original Message -----
From: "Vincent Finn" <vincent_finn_at_[hidden]>

> It looks quite good, nice and easy to read

> Have you done any time tests to see what the speed is like ?
not yet. a quick comparison between

#include "init.hpp"

int main()
    std::vector<int> v;
    init::set_cont( v ) = 1,2,3,4,5;


#include "vector"

int main()
    std::vector<int> v;
    v.push_back( 1 );
    v.push_back( 2 );
    v.push_back( 3 );
    v.push_back( 4 );
    v.push_back( 5 );

gives the same execuatble for Comeau 4.3. Gcc 2.95.3-10 is somewhat poor
compared. Not even -O2 can give the same binary size.
To be sure one would need to test all compilers. I suspect that gcc have
improved a lot since 2.95.10?

> Is there much of a hit by comparison to the uglier versions ??
Are you refereing to the enum stuff? I'm still not sure that the
'fenum_n_XX' should be more than implementation details.
That's why they are not documented on the page. Without running a
comparison, we can estimate the extra time. If the
container type is given as a parameter for this guy

template< typename T, typename Container >
Container fenum_n( size_t n, const Container& );

we get

vector<int> vi = fenum_n( 10, vi );

which will create an local vector<int> of size 10 and call std::generate on
all elements. Assuming the compiler can apply the "named return value
the time of the line above should be

fast_time = construction of vector + call to generate

if the slow interface is used the time will be

slow_time = fast_time + copying vector to new container

At first did not give a separate name via a preceeding 'f', but template
deduction became ambuguish between

enum_n( size_t, T step_size )
enum_n( size_t, const Container& )



Boost list run by bdawes at, gregod at, cpdaniel at, john at