问题
My question is rather simple, as Google has let me down. How do I convert an unbounded string to an integer?
If the string was bounded, I could do this: I : Integer := Integer'Value("613");
However, my string is unbounded, and Ada throws this error:
expected type "Standard.String"
found private type "Ada.Strings.Unbounded.Unbounded_String"
Is what I want to do possible?
回答1:
You just have to do the intermediate conversion:
I : Integer := Integer'Value (To_String (T));
Here is a full test program:
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
T : Unbounded_String := To_Unbounded_String ("613");
I : Integer := Integer'Value (To_String (T));
begin
Put_Line (I'Image);
end Main;
来源:https://stackoverflow.com/questions/42565836/convert-unbounded-string-to-integer-ada