ImmutableString: Remove std::unique_ptr<char[]> ctor overload

This commit is contained in:
Tatsuhiro Tsujikawa 2016-01-17 22:24:10 +09:00
parent 09de332028
commit 9f0f5c60ad
2 changed files with 3 additions and 11 deletions

View File

@ -232,10 +232,6 @@ public:
ImmutableString(const char *s, size_t slen) ImmutableString(const char *s, size_t slen)
: len(slen), base(copystr(s, len)) {} : len(slen), base(copystr(s, len)) {}
ImmutableString(const char *s) : len(strlen(s)), base(copystr(s, len)) {} ImmutableString(const char *s) : len(strlen(s)), base(copystr(s, len)) {}
ImmutableString(std::unique_ptr<char[]> s)
: len(strlen(s.get())), base(len == 0 ? "" : s.release()) {}
ImmutableString(std::unique_ptr<char[]> s, size_t slen)
: len(slen), base(len == 0 ? "" : s.release()) {}
ImmutableString(const std::string &s) ImmutableString(const std::string &s)
: len(s.size()), base(copystr(s.c_str(), s.size())) {} : len(s.size()), base(copystr(s.c_str(), s.size())) {}
template <typename InputIt> template <typename InputIt>

View File

@ -50,20 +50,16 @@ void test_template_immutable_string(void) {
CU_ASSERT(std::string("alpha") == from_cstr); CU_ASSERT(std::string("alpha") == from_cstr);
CU_ASSERT(from_cstr == std::string("alpha")); CU_ASSERT(from_cstr == std::string("alpha"));
ImmutableString from_uniq(strcopy("charlie"));
CU_ASSERT("charlie" == from_uniq);
CU_ASSERT(7 == from_uniq.size());
// copy constructor // copy constructor
ImmutableString copy = from_uniq; ImmutableString src("charlie");
ImmutableString copy = src;
CU_ASSERT("charlie" == copy); CU_ASSERT("charlie" == copy);
CU_ASSERT(7 == copy.size()); CU_ASSERT(7 == copy.size());
// copy assignment // copy assignment
ImmutableString copy2; ImmutableString copy2;
copy2 = from_uniq; copy2 = src;
CU_ASSERT("charlie" == copy2); CU_ASSERT("charlie" == copy2);
CU_ASSERT(7 == copy2.size()); CU_ASSERT(7 == copy2.size());