Ox String Types

Ox has six different major string types. These types are divided into two categories: store types and view types. String stores maintain a copy of the string data, whereas view types only maintain a reference to the data. Views should be used where you otherwise might use a const reference to a string store type. Having all of these different string types may sound like an interoperability nightmare, but taking string view types extensively where applicable makes the imagined interoperability issues virtually non-existent. ...

January 18, 2026 · 4 min · Gary Talent

MaybeView

Note: this is based on the version of Ox in following revision in the Nostalgia repo : 1b629da8fc658a85f07b5209f2791a5ebdf79fa1 Problem In C++, hash maps are often used with strings as keys. This would typically look something like this. std::unordered_map<std::string, int> ages; ages["Jerry Smith"] = 54; And here is an example of a lookup: int age = ages["Jerry Smith"]; There is a hidden inefficiency here. The lookup operator does not take a std::string_view or a C string. The lookup operator takes a std::string. That means, even though we are passing in a C string that has all the necessary data, we are implicitly calling the std::string constructor, which will allocate space on the heap for the string data, then copy the existing C string into the buffer it allocated. Then, as soon as the lookup call is finished, the temporary std::string is destroyed. ...

April 24, 2024 · 2 min · Gary Talent