diff --git a/alib2/src/regexp/Alternation.cpp b/alib2/src/regexp/Alternation.cpp index 47940ba5a5997eb34db1c51795d2cc5f0f6a3278..8f5c6618e7e68d50e18c5080c7d5eea9740b108f 100644 --- a/alib2/src/regexp/Alternation.cpp +++ b/alib2/src/regexp/Alternation.cpp @@ -44,8 +44,8 @@ Alternation::~Alternation() noexcept { elements.clear(); } -const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > Alternation::getElements() const { - return std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > >(elements.begin(), elements.end()); +const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > & Alternation::getElements() const { + return * reinterpret_cast<const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > * > (&elements); } void Alternation::insertElement(const RegExpElement& element) { diff --git a/alib2/src/regexp/Alternation.h b/alib2/src/regexp/Alternation.h index f76313d5f31cc4c485b465ddb62fa54305040ce7..d5fc72c94b3770af690af9286a23638751dc9b83 100644 --- a/alib2/src/regexp/Alternation.h +++ b/alib2/src/regexp/Alternation.h @@ -39,7 +39,7 @@ public: /** * @return elements */ - const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > getElements() const; + const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > & getElements() const; /** * @param element to insert diff --git a/alib2/src/regexp/Concatenation.cpp b/alib2/src/regexp/Concatenation.cpp index 9e25ba60799474b099a24aa7187a98b6809161c1..baff26388374d73693b45086abcb34dd3ee2c596 100644 --- a/alib2/src/regexp/Concatenation.cpp +++ b/alib2/src/regexp/Concatenation.cpp @@ -43,8 +43,8 @@ Concatenation::~Concatenation() noexcept { elements.clear(); } -const std::vector<std::shared_ptr<const RegExpElement> > Concatenation::getElements() const { - return std::vector<std::shared_ptr<const RegExpElement> >(elements.begin(), elements.end()); +const std::vector<std::shared_ptr<const RegExpElement> > & Concatenation::getElements() const { + return * reinterpret_cast<const std::vector<std::shared_ptr<const RegExpElement> > * > (&elements); } void Concatenation::appendElement(const RegExpElement& element) { diff --git a/alib2/src/regexp/Concatenation.h b/alib2/src/regexp/Concatenation.h index 30b13510d4b5884926a73ca78991aa0e2a626818..504e4570e0c4c191eaa9b8977b1a657a663c1e83 100644 --- a/alib2/src/regexp/Concatenation.h +++ b/alib2/src/regexp/Concatenation.h @@ -39,7 +39,7 @@ public: /** * @return elements */ - const std::vector<std::shared_ptr<const RegExpElement> > getElements() const; + const std::vector<std::shared_ptr<const RegExpElement> > & getElements() const; /** * @param element to append diff --git a/alib2/src/regexp/Iteration.cpp b/alib2/src/regexp/Iteration.cpp index 8a1017d3f1d323dc4401568a071d8da7eec5340a..06335296ddb6ed8db913aaf9f761be7c247c137a 100644 --- a/alib2/src/regexp/Iteration.cpp +++ b/alib2/src/regexp/Iteration.cpp @@ -42,8 +42,8 @@ regexp::Iteration::~Iteration() noexcept { } -const std::shared_ptr<const RegExpElement> Iteration::getElement() const { - return std::shared_ptr<const RegExpElement>(element); +const std::shared_ptr<const RegExpElement> & Iteration::getElement() const { + return * reinterpret_cast<const std::shared_ptr<const RegExpElement> * > (&element); } void Iteration::setElement(const RegExpElement& element) { diff --git a/alib2/src/regexp/Iteration.h b/alib2/src/regexp/Iteration.h index 16f134643bd0ec27df15e12520f93d06ced8be51..8b1d8d5e0e0213226bc11a6c07bcf9caec32f7f6 100644 --- a/alib2/src/regexp/Iteration.h +++ b/alib2/src/regexp/Iteration.h @@ -39,7 +39,7 @@ public: /** * @return element */ - const std::shared_ptr<const RegExpElement> getElement() const; + const std::shared_ptr<const RegExpElement> & getElement() const; /** * @param element to iterate