Hacker Newsnew | past | comments | ask | show | jobs | submit | gusthoff's commentslogin

Would you mind sharing which bounded container you tried to instantiate and what the problem was?


I wasn't able to instantiate any of them, I couldn't figure out the proper syntax. There are no examples anywhere that show how to used them.


Is this the kind of example you were looking for?

    with Ada.Text_IO;                    use Ada.Text_IO;
    with Ada.Containers.Bounded_Vectors;

    procedure Main is
       package BV_Integer is new
         Ada.Containers.Bounded_Vectors (Index_Type   => Positive,
                                         Element_Type => Integer);
       use BV_Integer;

       Vec_Max : constant := 10;
       Vec     : Vector (Vec_Max);
    begin
       Put_Line ("Appending some numbers...");
       for I in 1 .. Vec_Max loop
          Vec.Append (Integer (I));
       end loop;
       
       Put_Line ("Appending another number...");
       Vec.Append (Vec_Max + 1);   --  this raises an exception.
    end Main;


Yes, thanks. Perhaps I was just missing Vec : Vector (Vec_Max);. I'll give this a go on GNAT some time.


Not bad. However, I'm missing some newer, complementary stuff on the list. For example:

- Rationale for Ada 2005: http://www.adaic.org/resources/add_content/standards/05rat/h...

- Rationale for Ada 2012: http://www.ada-auth.org/standards/12rat/html/Rat12-TOC.html


Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: