Boost logo

Boost :

From: rwgk_at_[hidden]
Date: 2001-05-04 20:12:25


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


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