From 72da42a3a6160bc746da931dc97b5a570ef09ed8 Mon Sep 17 00:00:00 2001 From: Lixia Chen Date: Fri, 12 Mar 2021 09:19:52 -0500 Subject: [PATCH] Fix converting between optional string and char --- include/api/dual_abi_helper.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/api/dual_abi_helper.h b/include/api/dual_abi_helper.h index f94a3daa882..7d56d5ac72d 100644 --- a/include/api/dual_abi_helper.h +++ b/include/api/dual_abi_helper.h @@ -32,13 +32,15 @@ inline std::vector StringToChar(const std::string &s) { return std::vector inline std::string CharToString(const std::vector &c) { return std::string(c.begin(), c.end()); } inline std::optional> OptionalStringToChar(const std::optional &s) { + if (s == std::nullopt) return std::nullopt; std::optional> ret = std::vector(s->begin(), s->end()); - return (s == std::nullopt) ? std::nullopt : ret; + return ret; } inline std::optional OptionalCharToString(const std::optional> &c) { + if (c == std::nullopt) return std::nullopt; std::optional ret = std::string(c->begin(), c->end()); - return (c == std::nullopt) ? std::nullopt : ret; + return ret; } inline std::pair, int32_t> PairStringToChar(const std::pair &s) {