|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-05-13 19:34:32
Thanks Ralf,
just FYI, std::size_t is an unsigned type; there's never a need to check
whether it's less than zero. On some compilers this will raise a warning.
Regards,
Dave
----- Original Message -----
From: <rwgk_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, May 04, 2001 9:12 PM
Subject: [boost] Re: BPL: Easiest way to return a private vector<long> ?
> The new version of simple_vector.cpp (CVS tree) checks the
> indices passed to __getitem__ etc., e.g.:
>
> void raise_vector_IndexError() {
> PyErr_SetString(PyExc_IndexError, "IndexError: vector index out
> of range");
> throw python::error_already_set();
> }
>
> double getitem(const std::vector<double>& vd, std::size_t key) {
> if (key < 0 || key >= vd.size()) raise_vector_IndexError();
> return vd[key];
> }
>
> This test now works as expected:
> >>> v=simple_vector.vector_double((3,4,5))
> >>> for e in v:
> ... print e
> 3.0
> 4.0
> 5.0
>
> Ralf
>
> --- In boost_at_y..., jk_at_s... wrote:
> > 4 May 2001 11:25:20 +0400 Jens Maurer wrote:
> > >> return vd.at(key);
> > >> }
> > >>
> > >> This compiles fine with VC60, Compaq cxx, Silicon Graphics CC,
> > >> but NOT with gcc-2.95.2 (RedHat 6.1):
> > >
> > >gcc 2.95.2 has an outdated library which does not support
> > >std::vector<>::at().
> >
> > It is library problem, the core compiler with STLport works fine
> (my $0.02).
> >
> > --
> > jk
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk