88Vector
99******
1010
11- Vectors are resizeable arrays of elements. All vectors support the following
12- basic operations.
11+ Vectors are resizeable arrays of elements. The ``flc_vector `` module
12+ instantiates vectors of ``integer(4) ``, ``integer(8) ``, ``real(8) ``, and
13+ ``type(String) ``.
14+
15+ Common functionality
16+ ====================
17+
18+ All vector types support the following basic operations.
1319
1420Construction and destruction
1521----------------------------
@@ -77,6 +83,14 @@ The size of a vector is returned by the bound function ``size``; ``get``
7783returns the value at an index; and ``front `` and ``back `` are aliases for
7884``get(1) `` and ``get(v%size()) ``, respectively.
7985
86+ Additionally, ``front_ref ``, ``back_ref ``, and ``get_ref `` return pointers to
87+ the elements of the array.
88+
89+ .. warning :: Array element pointers are valid **only** as long as the vector's
90+ size is not changed. Calling ``erase ``, ``push_back ``, and so forth will
91+ invalidate the pointer; accessing it at that point results in undefined
92+ behavior.
93+
8094Numeric vectors
8195===============
8296
@@ -100,6 +114,8 @@ an array pointer::
100114 v = Vector(iarr)
101115 write(0,*) "Size should be 4:", v%size()
102116
117+ The ``assign `` bound method acts like a constructor but for an existing vector.
118+
103119View as an array pointer
104120------------------------
105121
@@ -124,7 +140,20 @@ underlying memory as the C++ object::
124140String vectors
125141==============
126142
127- String vectors are not yet implemented.
143+ String vectors' native "element" type is a ``character(len=:) ``. Vector
144+ operations that accept an input will take any native character string; and
145+ returned values will be allocatable character arrays.
146+
147+ The ``front_ref ``, ``back_ref ``, and ``get_ref `` functions allow the underlying
148+ ``std::string `` class to be accessed with the ``String `` Fortran derived type
149+ wrapper. Note that unlike for intrinsic types, where these functions return a
150+ ``integer, pointer ``, the vector of strings returns just ``type(String) ``.
151+ However, as with native pointers described above, these references are
152+ *invalid * once the string changes size. They should be cleared with the
153+ ``%release() `` bound method.
154+
155+ An additional ``set_ref `` function allows vector elements to be assigned from
156+ vector classes.
128157
129158.. ############################################################################
130159.. end of doc/modules/vector.rst
0 commit comments