Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-01

FCL-STL's TVector<T> and removing of elements

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth

Hello together!

Can it be that the TVector<T> type of FCL-STL has some problems when deleting elements?

At least the following code generates an exception when running it:

program fclstltest1;
{$mode objfpc}
uses
   gvector;
type
   TMyVector = specialize TVector<LongInt>;
var
   v: TMyVector;
begin
   v := TMyVector.Create;
   v.PushBack(42);
   v.Erase(0);
   v.Free;
end.

When using AnsiString or ShortString there the exception appears in fpc_ansistr_assign and fpc_shortstr_to_shortstr respectively.

Am I doing something wrong here or is this indeed a bug?

Regards,
Sven

Reply by email

Kornel Kisielewicz
to Sven Barth
Sven Barth wrote 13 lines
Hello together! Can it be that the TVector<T> type of FCL-STL has some problems when deleting elements? At least the following code generates an exception when running it: program fclstltest1; {$mode objfpc} uses  gvector;

Woah, where is that unit from?

regards, Kornel Kisielewicz

Reply by email

Sven Barth
to Kornel Kisielewicz
Kornel Kisielewicz wrote 16 lines
On Sat, Jan 28, 2012 at 7:30 PM, Sven Barth wrote: > Hello together! > > Can it be that the TVector<T> type of FCL-STL has some problems when > deleting elements? > > At least the following code generates an exception when running it: > > program fclstltest1; > > {$mode objfpc} > > uses > gvector; Woah, where is that unit from?

It's part of FPC's packages in 2.7.1 (package fcl-stl). They also compile in 2.6.0 if you download their source.

Regards,
Sven

Reply by email

Kornel Kisielewicz
to Sven Barth
Sven Barth wrote 6 lines
On 28.01.2012 20:10, Kornel Kisielewicz wrote: > Woah, where is that unit from? It's part of FPC's packages in 2.7.1 (package fcl-stl). They also compile in 2.6.0 if you download their source.

I just wondered because I once did the same - a partial STL port to FPC, with (maximum possible for that moment) C++03 Standard compatibility. Gave up when some of the more interesting features based on Iterators and Function objects proved to be impossible to port.

I've looked at the implementation and it looks pretty primitive for being a part of FCL (not to mention that it's not even trying to follow the Standard). The FGL unit generics are much better designed and robust.

regards, Kornel Kisielewicz

Reply by email

Sven Barth
to Kornel Kisielewicz
Kornel Kisielewicz wrote 19 lines
On Sat, Jan 28, 2012 at 9:27 PM, Sven Barth wrote: > On 28.01.2012 20:10, Kornel Kisielewicz wrote: >> Woah, where is that unit from? > > > It's part of FPC's packages in 2.7.1 (package fcl-stl). They also compile in > 2.6.0 if you download their source. I just wondered because I once did the same - a partial STL port to FPC, with (maximum possible for that moment) C++03 Standard compatibility. Gave up when some of the more interesting features based on Iterators and Function objects proved to be impossible to port. I've looked at the implementation and it looks pretty primitive for being a part of FCL (not to mention that it's not even trying to follow the Standard). The FGL unit generics are much better designed and robust.

At least for those two that I've used till now (TMap and TVector) I agree with you.

Regards,
Sven

Reply by email