summaryrefslogtreecommitdiffstats
path: root/Source/cmString.hxx
Commit message (Collapse)AuthorAgeFilesLines
* clang-tidy: Replace typedef with usingRegina Pfeifer2019-09-041-1/+1
| | | | | | | | Automate the conversion with perl -i -0pe 's/typedef ([^;]*) ([^ ]+);/using $2 = $1;/g' then manually fix a few places.
* clang-tidy: Replace typedef with usingRegina Pfeifer2019-09-031-3/+3
|
* IWYU: Add missing cstddef includes for size_t and nullptr_tBrad King2019-09-031-0/+1
| | | | The IWYU tool we use for CI now diagnoses these.
* IWYU: Update CMake code for IWYU built with Clang 6Brad King2019-01-151-0/+1
| | | | | IWYU now correctly requires `<utility>` for `std::move`. It also requires a container header when used via a range-based for loop.
* clang-tidy: Remove redundant member initializationsRegina Pfeifer2018-12-151-2/+1
|
* String: Add str_if_stable() as a const alternative to str()Brad King2018-12-121-0/+14
| | | | | | | | | | | | | | | | The `str()` method must be non-const because it may need to internally mutate the representation of the string in order to have an owned `std::string` instance holding the exact string (not a superstring). This is inconvenient in contexts where we can ensure that no mutation is needed to get a `std::string const&`. Add a `str_if_stable() const` method that returns `std::string const*` so we can return `nullptr` if if mutation would be necessary to get a `std::string const&`. Add supporting `is_stable() const` and `stabilize()` methods to check and enforce stable availability of `std::string const&`. These can be used to create `String const` instances from which we can still get a `std::string const&` via `*str_if_stable()` by maintaining the stability invariant at runtime.
* String: Add support for a ""_s string literal syntaxBrad King2018-12-121-1/+14
| | | | | Create a `static_string_view` type that binds only to the static storage of string literals. Teach `cm::String` to borrow from these implicitly.
* String: Add 'borrow' member to construct borrowing instancesBrad King2018-12-121-0/+4
| | | | | | This will allow creation of `cm::String` instances that borrow from non-owned storage. It is the caller's responsibility to ensure that no copy of the instance outlives the borrowed buffer.
* String: Add support for concatenation by operator+Brad King2018-12-121-0/+101
| | | | | | Use expression templates to collect the entire expression and pre-allocate a string with the final length before concatenating the pieces.
* String: Add a custom string typeBrad King2018-12-121-0/+683
Create a `cm::String` type that holds a view of a string buffer and optionally shares ownership of the buffer. Instances can either borrow longer-lived storage (e.g. static storage of string literals) or internally own a `std::string` instance. In the latter case, share ownership with copies and substrings. Allocate a new internal string only on operations that require mutation. This will allow us to recover string sharing semantics that we used to get from C++98 std::string copy-on-write implementations. Such implementations are not allowed by C++11 so code our own in a custom string type instead.