mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-25 02:50:33 +00:00
sstring: constructor from C string
The constructor from "const char_type *" wouldn't really work when char_type != char, because strlen() won't work on such pointers. It is more convenient to have a constructor from an ordinary const char * (e.g., a C string literal), and solve the type problem with an ugly cast. This only makes sense when sizeof(char_type)==1 (i.e., it is char, unsigned char, or signed char), but I think we make this assumption in other places as well (e.g., in determining the size we need to allocate). Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
This commit is contained in:
@@ -105,7 +105,7 @@ public:
|
||||
u.external.str[size] = '\0';
|
||||
}
|
||||
}
|
||||
basic_sstring(const char_type* x) : basic_sstring(x, std::strlen(x)) {}
|
||||
basic_sstring(const char* x) : basic_sstring(reinterpret_cast<const char_type*>(x), std::strlen(x)) {}
|
||||
basic_sstring(std::basic_string<char_type>& x) : basic_sstring(x.c_str(), x.size()) {}
|
||||
basic_sstring(std::initializer_list<char_type> x) : basic_sstring(x.begin(), x.end() - x.begin()) {}
|
||||
basic_sstring(const char_type* b, const char_type* e) : basic_sstring(b, e - b) {}
|
||||
|
||||
Reference in New Issue
Block a user