1 // Scintilla source code edit control
2 /** @file UniqueString.h
3 ** Define UniqueString, a unique_ptr based string type for storage in containers
4 ** and an allocator for UniqueString.
6 // Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
7 // The License.txt file describes the conditions under which this software may be distributed.
10 #define UNIQUESTRING_H
14 using UniqueString
= std::unique_ptr
<const char[]>;
16 /// Equivalent to strdup but produces a std::unique_ptr<const char[]> allocation to go
18 inline UniqueString
UniqueStringCopy(const char *text
) {
20 return UniqueString();
22 const size_t len
= strlen(text
);
23 char *sNew
= new char[len
+ 1];
24 std::copy(text
, text
+ len
+ 1, sNew
);
25 return UniqueString(sNew
);