diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index 0255bcd1..8a34e981 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -22,6 +22,10 @@ #include +#if __cplusplus >= 201703L +# include +#endif + START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- @@ -49,10 +53,7 @@ public: fBufferLen(0), fBufferAlloc(false) { - char ch[2]; - ch[0] = c; - ch[1] = '\0'; - + const char ch[2] = { c, '\0' }; _dup(ch); } @@ -87,6 +88,19 @@ public: _dup(strBuf); } + #if __cplusplus >= 201703L + /* + * std::string_view compatible variant. + */ + explicit String(const std::string_view& strView) noexcept + : fBuffer(_null()), + fBufferLen(0), + fBufferAlloc(false) + { + _dup(strView.data(), strView.size()); + } + #endif + /* * Integer. */