Created
May 16, 2019 14:39
-
-
Save sigman78/038a6eebaed7052b753e6578ae41f540 to your computer and use it in GitHub Desktop.
constexpr cstr mockup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constexpr const char* end_of(const char* s) { | |
while (*s != 0) ++s; | |
return s; | |
} | |
struct cstr { | |
const char* b_; | |
const char* e_; | |
constexpr cstr(const char* s) | |
: b_(s) | |
, e_(end_of(s)) | |
{} | |
operator std::string () const { | |
return std::string{b_, e_}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment