forked from mindspore-Ecosystem/mindspore
Fix converting between optional string and char
This commit is contained in:
parent
9add98350e
commit
72da42a3a6
|
@ -32,13 +32,15 @@ inline std::vector<char> StringToChar(const std::string &s) { return std::vector
|
|||
inline std::string CharToString(const std::vector<char> &c) { return std::string(c.begin(), c.end()); }
|
||||
|
||||
inline std::optional<std::vector<char>> OptionalStringToChar(const std::optional<std::string> &s) {
|
||||
if (s == std::nullopt) return std::nullopt;
|
||||
std::optional<std::vector<char>> ret = std::vector<char>(s->begin(), s->end());
|
||||
return (s == std::nullopt) ? std::nullopt : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline std::optional<std::string> OptionalCharToString(const std::optional<std::vector<char>> &c) {
|
||||
if (c == std::nullopt) return std::nullopt;
|
||||
std::optional<std::string> ret = std::string(c->begin(), c->end());
|
||||
return (c == std::nullopt) ? std::nullopt : ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline std::pair<std::vector<char>, int32_t> PairStringToChar(const std::pair<std::string, int32_t> &s) {
|
||||
|
|
Loading…
Reference in New Issue