$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Damien Fisher (damien_at_[hidden])
Date: 2002-05-15 20:51:12
On Wed, 15 May 2002, David Abrahams wrote:
> > On Thu, 16 May 2002, Damien Fisher wrote:
> >
> > > template<typename Container>
> > > bool is_n_elements(const Container &cont, unsigned int n)
> > > {
> > > // ...
> > > }
> >
> > I should point out that this function would have complexity O(n), where
> > n is the parameter passed in, whereas using std::list<T>::size() would
> > result in complexity O(m), where m is the size of the list. Using the
> > above would then only really be necessary/useful if m >> n.
>
> But the implementation you supplied invokes undefined behavior when used on
> empty containers.
That's easily fixed. The implementation was totally off the top of my
head and purely for expository purposes.