help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: for "vector<int,allocator<int> > vx;" must I erase using something


From: llewelly
Subject: Re: for "vector<int,allocator<int> > vx;" must I erase using something like "vx.erase(vx.begin()+2);" or may the "at" command be somehow used? "vx.erase(vx.at(2));"
Date: Thu, 29 Apr 2004 23:30:46 -0600
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (berkeley-unix)

"Leland T. Snyder" <ltsnyder@x3CI.com> writes:

> This must be either a change in the ISO standard, or a variance in the way
> GNU g++ treats vector::at becuase this is an example that use to work (in
> another C++ compiler).

What used to work? With which compiler?

> Is the convention now to only refererence using and increment from
> begin?

? Could you post an example which 

> I'd look this up in a manual if it wern't for the fact that "at" is such a
> common word it becomes utterly unsearchable.

std::container<>::erase() is described in 23.1.1 table 67 and
    paragraph 7. std::container<>::at() is described in table 68 and
    paragraph 12 (same section.) 

>
> I know this is symantics and either was is just as terse, just want some
> clarification.
>
> I'm sure posting the compile error message is overkill here.

Actually, it is insufficient. Please post a short-but-complete
    example which will reproduce the error you report.

> vector.C:98: error: no matching function for call to `std::vector<int,
>    std::allocator<int> >::erase(int&)'

You must pass an iterator to erase.

> /usr/include/g++/bits/vector.tcc:105: error: candidates are:
>    __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
>    std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
>    std::vector<_Tp, _Alloc> >) [with _Tp = int, _Alloc =
> std::allocator<int>]
> /usr/include/g++/bits/vector.tcc:117: error:
>    __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
>    std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
>    std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<_Tp*,
>    std::vector<_Tp, _Alloc> >) [with _Tp = int, _Alloc =
> std::allocator<int>]
> -bash: ./vector: No such file or directory


reply via email to

[Prev in Thread] Current Thread [Next in Thread]