https://github.com/bindreams/cxstring
Compile-time string class
https://github.com/bindreams/cxstring
Last synced: 8 months ago
JSON representation
Compile-time string class
- Host: GitHub
- URL: https://github.com/bindreams/cxstring
- Owner: bindreams
- Created: 2019-02-24T20:33:04.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T15:14:19.000Z (about 1 year ago)
- Last Synced: 2025-06-11T15:39:23.935Z (11 months ago)
- Language: C++
- Size: 7.81 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cxstring
A string class for compile-time string manipulation.
Inspired by this [blog post](https://akrzemi1.wordpress.com/2017/06/28/compile-time-string-concatenation/), this library expands on the idea by implementing all relevant string methods, modernizing the approach, and providing additional features such as compile-time number-to-string conversion.
## Installation
`cxstring` is a single-header library. There are no public releases available yet, but you can use the library in its "unwrapped" form by copying the cxstring folder into your project's directory, or manually build the single header from root-level cxstring.hpp.
Using `cxstring` requires C++17 support.
## Usage
Including the library:
```c++
#include "cxstring.hpp"
```
Creating a `cxstring`:
```c++
zh::cxstring cxstr = "Hello there!"; // Deduced type: zh::cxstring<12> (12 symbols, \0 does not count)
```
Concatenating string literals:
```c++
auto cxstr =
zh::cxstring("General") +
zh::cxstring(" ") +
zh::cxstring("Kenobi!");
// Deduced type: zh::cxstring<15>
```
Getting a string literal out, to not scare your users with your crazy libraries:
```c++
const auto& literal1 = cxstr.data(); // type: reference to const char array of the appropriate size
const auto& literal2 = cxstr.substr<7>(8).data();
// size^ ^start
```
## License
This project is licenced under the MIT licence. It is free for personal and commercial use.