From 92fddd7e42dee1437e301f176fe2ad0342cb14e8 Mon Sep 17 00:00:00 2001 From: Arek Sredzki Date: Fri, 1 Mar 2019 11:31:54 -0800 Subject: [PATCH] Add const ref istring constructors (#119) --- include/etl/cstring.h | 10 ++++++++++ include/etl/u16string.h | 10 ++++++++++ include/etl/u32string.h | 10 ++++++++++ include/etl/wstring.h | 10 ++++++++++ 4 files changed, 40 insertions(+) diff --git a/include/etl/cstring.h b/include/etl/cstring.h index 01ff2d12..3dea5592 100644 --- a/include/etl/cstring.h +++ b/include/etl/cstring.h @@ -78,6 +78,16 @@ namespace etl this->assign(other.begin(), other.end()); } + //************************************************************************* + /// From other istring. + ///\param other The other istring. + //************************************************************************* + string(const etl::istring& other) + : istring(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(other.begin(), other.end()); + } + //************************************************************************* /// From other string, position, length. ///\param other The other string. diff --git a/include/etl/u16string.h b/include/etl/u16string.h index d496f094..ef864d63 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -79,6 +79,16 @@ namespace etl this->assign(other.begin(), other.end()); } + //************************************************************************* + /// From other iu16string. + ///\param other The other iu16string. + //************************************************************************* + u16string(const etl::iu16string& other) + : iu16string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(other.begin(), other.end()); + } + //************************************************************************* /// From other string, position, length. ///\param other The other string. diff --git a/include/etl/u32string.h b/include/etl/u32string.h index bc076373..7684f9aa 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -79,6 +79,16 @@ namespace etl this->assign(other.begin(), other.end()); } + //************************************************************************* + /// From other iu32string. + ///\param other The other iu32string. + //************************************************************************* + u32string(const etl::iu32string& other) + : iu32string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(other.begin(), other.end()); + } + //************************************************************************* /// From other string, position, length. ///\param other The other string. diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 206f7253..8272953c 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -79,6 +79,16 @@ namespace etl wstring::assign(other.begin(), other.end()); } + //************************************************************************* + /// From other iwstring. + ///\param other The other iwstring. + //************************************************************************* + wstring(const etl::iwstring& other) + : iwstring(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(other.begin(), other.end()); + } + //************************************************************************* /// From other string, position, length.