summaryrefslogtreecommitdiffstats
path: root/doc/string_views.rst
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-05-10 16:00:29 -0400
committerDavid Robillard <d@drobilla.net>2023-05-10 18:27:55 -0400
commit67526c25f4a751be27d2f9eed38d07fe52342aa5 (patch)
tree69039501fb0c15d6386d2fe73174af47085f673f /doc/string_views.rst
parentff5104de74122477459b48df8b046d06d2db506b (diff)
downloadzix-67526c25f4a751be27d2f9eed38d07fe52342aa5.tar.gz
zix-67526c25f4a751be27d2f9eed38d07fe52342aa5.tar.bz2
zix-67526c25f4a751be27d2f9eed38d07fe52342aa5.zip
Add ZIX_STATIC_STRING()
Diffstat (limited to 'doc/string_views.rst')
-rw-r--r--doc/string_views.rst13
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/string_views.rst b/doc/string_views.rst
index b6e3fd9..6c049f3 100644
--- a/doc/string_views.rst
+++ b/doc/string_views.rst
@@ -1,5 +1,5 @@
..
- Copyright 2020-2022 David Robillard <d@drobilla.net>
+ Copyright 2020-2023 David Robillard <d@drobilla.net>
SPDX-License-Identifier: ISC
String Views
@@ -15,6 +15,17 @@ This forces code to be explicit about string measurement,
which discourages common patterns of repeated measurement of the same string.
For convenience, several macros and functions are provided for constructing string views:
+:macro:`ZIX_STATIC_STRING`
+
+ Initializes a string view from a string literal. Note that this may only be
+ used with inlined string literals, passing a pointer to an arbitrary string
+ is undefined behaviour, for example:
+
+ .. literalinclude:: overview_code.c
+ :start-after: begin make-static-string
+ :end-before: end make-static-string
+ :dedent: 2
+
:func:`zix_empty_string`
Constructs a view of an empty string, for example: