From c226414e0c0e804f9635914667b2c20747bc26c3 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sun, 19 Aug 2018 13:09:00 +0200 Subject: Use std::make_optional --- src/cppc4group.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/cppc4group.cpp b/src/cppc4group.cpp index fa64771..0619f75 100644 --- a/src/cppc4group.cpp +++ b/src/cppc4group.cpp @@ -67,7 +67,7 @@ std::optional CppC4Group::getEntryData(const std::string& path size_t size; if(cc4group.getEntryData(p->g, path.c_str(), &data, &size)) { - return {{data, size}}; + return std::make_optional(data, size); } else { @@ -155,8 +155,9 @@ std::optional CppC4Group::getEntryInfo(const std::string& CC4Group_EntryInfo info; if(cc4group.getEntryInfo(p->g, path.c_str(), &info)) { - CppC4Group::EntryInfo entryInfo; - return fillEntryInfo(entryInfo, info); + auto entryInfo = std::make_optional(); + fillEntryInfo(*entryInfo, info); + return entryInfo; } else { @@ -164,19 +165,18 @@ std::optional CppC4Group::getEntryInfo(const std::string& } } -std::optional > CppC4Group::getEntryInfos(const std::string& path) +std::optional> CppC4Group::getEntryInfos(const std::string& path) { CC4Group_EntryInfo* infos; size_t infoCount; if(cc4group.getEntryInfos(p->g, path.c_str(), &infos, &infoCount)) { - std::vector entryInfos; - entryInfos.reserve(infoCount); + auto entryInfos = std::make_optional>(infoCount); for(size_t i = 0; i < infoCount; ++i) { - fillEntryInfo(entryInfos.emplace_back(), infos[i]); + fillEntryInfo((*entryInfos)[i], infos[i]); } free(infos); -- cgit v1.2.3-54-g00ecf