diff --git a/.gitmodules b/.gitmodules index 6a92e8492..6dc46bab5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,15 +7,9 @@ [submodule "external/cxxopts"] path = external/cxxopts url = https://github.com/jarro2783/cxxopts.git -[submodule "external/ghc-filesystem"] - path = external/ghc-filesystem - url = https://github.com/gulrak/filesystem.git [submodule "test/Catch2"] path = test/Catch2 url = https://github.com/catchorg/Catch2 -[submodule "external/optional-lite"] - path = external/optional-lite - url = https://github.com/martinmoene/optional-lite.git [submodule "external/date"] path = external/date url = https://github.com/HowardHinnant/date.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f568ea7ee..ab4463617 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include(MacroEnsureOutOfSourceBuild) macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out-of-source build. Create a build directory and run 'cmake ${CMAKE_SOURCE_DIR} [options]'.") +set(CMAKE_CXX_STANDARD 17) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) + include(cmake/unix.cmake) if(NOT WIN32) @@ -97,14 +105,6 @@ if(NOT WIN32) endif() endif() -set(CMAKE_CXX_STANDARD 14) - -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_C_STANDARD 99) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS OFF) - # this is messing with release builds add_compile_options(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0) @@ -276,16 +276,16 @@ if(SUBMODULE_CHECK) check_submodule(external/nlohmann) check_submodule(external/googletest) check_submodule(external/cxxopts) - check_submodule(external/ghc-filesystem) - check_submodule(external/optional-lite) check_submodule(external/date) check_submodule(external/pybind11) endif() endif() -if(WITH_HIVE) - add_subdirectory(external/pybind11 EXCLUDE_FROM_ALL) -endif() +# We only actually need pybind11 with WITH_HIVE, but if we don't load it here then something further +# down loads a broken PythonInterp that loads Python2, but Python2 headers are not C++17 compatible. +# So load this here universally so that pybind's more intelligent python finder finds python3.x +# (which the crappier loader invoked below then respects). +add_subdirectory(external/pybind11 EXCLUDE_FROM_ALL) if(WITH_TESTS) add_subdirectory(external/googletest EXCLUDE_FROM_ALL) @@ -294,8 +294,6 @@ endif() set(JSON_BuildTests OFF CACHE INTERNAL "") add_subdirectory(external/nlohmann EXCLUDE_FROM_ALL) add_subdirectory(external/cxxopts EXCLUDE_FROM_ALL) -add_subdirectory(external/ghc-filesystem) -add_subdirectory(external/optional-lite EXCLUDE_FROM_ALL) add_subdirectory(external/date EXCLUDE_FROM_ALL) if(ANDROID) diff --git a/cmake/unix.cmake b/cmake/unix.cmake index 58b8a415d..90470b1a7 100644 --- a/cmake/unix.cmake +++ b/cmake/unix.cmake @@ -67,8 +67,6 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "i list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-darwin.c ${TT_ROOT}/tuntap-unix-bsd.c) elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-unix-sunos.c) - # Apple C++ screws up name decorations in stdc++fs, causing link to fail - # Samsung does not build c++experimental or c++fs in their Apple libc++ pkgsrc build if (LIBUV_USE_STATIC) link_libraries(-lkstat -lsendfile) endif() @@ -78,6 +76,40 @@ endif() set(EXE_LIBS ${STATIC_LIB}) + +# Figure out if we need -lstdc++fs or -lc++fs and add it to the `filesystem` interface, if needed +# (otherwise just leave it an empty interface library; linking to it will do nothing). The former +# is needed for gcc before v9, and the latter with libc++ before llvm v9. But this gets more +# complicated than just using the compiler, because clang on linux by default uses libstdc++, so +# we'll just give up and see what works. + +add_library(filesystem INTERFACE) + +set(filesystem_code [[ +#include + +int main() { + auto cwd = std::filesystem::current_path(); + return !cwd.string().empty(); +} +]]) + +check_cxx_source_compiles("${filesystem_code}" filesystem_compiled) +if(filesystem_compiled) + message(STATUS "No extra link flag needed for std::filesystem") +else() + foreach(fslib stdc++fs c++fs) + set(CMAKE_REQUIRED_LIBRARIES -l${fslib}) + check_cxx_source_compiles("${filesystem_code}" filesystem_compiled_${fslib}) + if (filesystem_compiled_${fslib}) + message(STATUS "Using -l${fslib} for std::filesystem support") + target_link_libraries(filesystem INTERFACE ${fslib}) + break() + endif() + endforeach() +endif() +unset(CMAKE_REQUIRED_LIBRARIES) + if(RELEASE_MOTTO) add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}") endif() diff --git a/external/ghc-filesystem b/external/ghc-filesystem deleted file mode 160000 index e63a58c5b..000000000 --- a/external/ghc-filesystem +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e63a58c5bac94a3a75a7083f87bb092531407a92 diff --git a/external/optional-lite b/external/optional-lite deleted file mode 160000 index 3b79f4ee5..000000000 --- a/external/optional-lite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3b79f4ee539d8f4c709a76b95a13564b6d9ae9cb diff --git a/include/llarp.hpp b/include/llarp.hpp index 5a58da2d1..187cbde83 100644 --- a/include/llarp.hpp +++ b/include/llarp.hpp @@ -73,7 +73,7 @@ namespace llarp HandleSignal(int sig); bool - Configure(bool isRelay, nonstd::optional dataDir); + Configure(bool isRelay, std::optional dataDir); bool IsUp() const; diff --git a/libabyss/include/abyss/client.hpp b/libabyss/include/abyss/client.hpp index 103f921b3..ca065ca47 100644 --- a/libabyss/include/abyss/client.hpp +++ b/libabyss/include/abyss/client.hpp @@ -3,7 +3,6 @@ #include #include -#include #include #include diff --git a/libabyss/include/abyss/http.hpp b/libabyss/include/abyss/http.hpp index 9313f07a8..8432d22e1 100644 --- a/libabyss/include/abyss/http.hpp +++ b/libabyss/include/abyss/http.hpp @@ -1,9 +1,9 @@ #ifndef ABYSS_HTTP_HPP #define ABYSS_HTTP_HPP #include -#include #include +#include #include namespace abyss @@ -20,18 +20,16 @@ namespace abyss struct HeaderReader { - using string_view = llarp::string_view; - RequestHeader Header; virtual ~HeaderReader() { } bool - ProcessHeaderLine(string_view line, bool& done); + ProcessHeaderLine(std::string_view line, bool& done); virtual bool - ShouldProcessHeader(const string_view& line) const = 0; + ShouldProcessHeader(std::string_view line) const = 0; }; } // namespace http diff --git a/libabyss/include/abyss/server.hpp b/libabyss/include/abyss/server.hpp index 158d91053..ee4a615fa 100644 --- a/libabyss/include/abyss/server.hpp +++ b/libabyss/include/abyss/server.hpp @@ -3,12 +3,10 @@ #include #include -#include #include #include #include -#include #include #include diff --git a/libabyss/src/client.cpp b/libabyss/src/client.cpp index c4ae340ee..cf5e6a98a 100644 --- a/libabyss/src/client.cpp +++ b/libabyss/src/client.cpp @@ -9,6 +9,7 @@ namespace abyss { namespace http { + using namespace std::literals; namespace json = llarp::json; struct ConnImpl : HeaderReader { @@ -85,35 +86,35 @@ namespace abyss } bool - ProcessStatusLine(string_view line) + ProcessStatusLine(std::string_view line) { auto idx = line.find_first_of(' '); - if (idx == string_view::npos) + if (idx == std::string_view::npos) return false; - string_view codePart = line.substr(1 + idx); + std::string_view codePart = line.substr(1 + idx); idx = codePart.find_first_of(' '); - if (idx == string_view::npos) + if (idx == std::string_view::npos) return false; return HandleStatusCode(codePart.substr(0, idx)); } bool - ShouldProcessHeader(const llarp::string_view& name) const + ShouldProcessHeader(std::string_view name) const { - return name == llarp::string_view("content-length") - || name == llarp::string_view("content-type") - || name == llarp::string_view("www-authenticate"); + return name == "content-length"sv + || name == "content-type"sv + || name == "www-authenticate"sv; } /// return true if we get a 200 status code bool - HandleStatusCode(string_view code) + HandleStatusCode(std::string_view code) { - if (code == string_view("200")) + if (code == "200"sv) return true; - if (code == string_view("401")) + if (code == "401"sv) { m_ShouldAuth = true; return true; @@ -259,7 +260,7 @@ namespace abyss const char* end = strstr(buf, "\r\n"); if (!end) return false; - string_view line(buf, end - buf); + std::string_view line(buf, end - buf); switch (state) { case eReadStatusLine: diff --git a/libabyss/src/http.cpp b/libabyss/src/http.cpp index d58bce2fb..d702726fc 100644 --- a/libabyss/src/http.cpp +++ b/libabyss/src/http.cpp @@ -1,11 +1,14 @@ #include +#include + #include + namespace abyss { namespace http { bool - HeaderReader::ProcessHeaderLine(string_view line, bool& done) + HeaderReader::ProcessHeaderLine(std::string_view line, bool& done) { if (line.size() == 0) { @@ -13,10 +16,10 @@ namespace abyss return true; } auto idx = line.find_first_of(':'); - if (idx == string_view::npos) + if (idx == std::string_view::npos) return false; - string_view header = line.substr(0, idx); - string_view val = line.substr(1 + idx); + std::string_view header = line.substr(0, idx); + std::string_view val = line.substr(1 + idx); // to lowercase std::string lowerHeader; lowerHeader.reserve(header.size()); diff --git a/libabyss/src/server.cpp b/libabyss/src/server.cpp index 3335b1010..42053ea22 100644 --- a/libabyss/src/server.cpp +++ b/libabyss/src/server.cpp @@ -8,12 +8,14 @@ #include #include #include +#include #include namespace abyss { namespace httpd { + using namespace std::literals; namespace json = llarp::json; struct ConnImpl : abyss::http::HeaderReader { @@ -76,15 +78,15 @@ namespace abyss } bool - ProcessMethodLine(string_view line) + ProcessMethodLine(std::string_view line) { auto idx = line.find_first_of(' '); - if (idx == string_view::npos) + if (idx == std::string_view::npos) return false; Header.Method = std::string(line.substr(0, idx)); line = line.substr(idx + 1); idx = line.find_first_of(' '); - if (idx == string_view::npos) + if (idx == std::string_view::npos) return false; Header.Path = std::string(line.substr(0, idx)); m_State = eReadHTTPHeaders; @@ -92,11 +94,10 @@ namespace abyss } bool - ShouldProcessHeader(const string_view& name) const + ShouldProcessHeader(std::string_view name) const { // TODO: header whitelist - return name == string_view("content-type") || name == string_view("content-length") - || name == string_view("host"); + return name == "content-type"sv || name == "content-length"sv || name == "host"sv; } bool @@ -138,7 +139,7 @@ namespace abyss return WriteResponseSimple( 415, "Unsupported Media Type", "text/plain", "no content type provided"); } - else if (itr->second != string_view("application/json")) + else if (itr->second != "application/json"sv) { return WriteResponseSimple( 415, "Unsupported Media Type", "text/plain", "this does not look like jsonrpc 2.0"); @@ -231,7 +232,7 @@ namespace abyss const char* end = strstr(buf, "\r\n"); while (end) { - string_view line(buf, end - buf); + std::string_view line(buf, end - buf); switch (m_State) { case eReadHTTPMethodLine: diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 6e7130033..f1834aa1c 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -44,8 +44,7 @@ endif() target_link_libraries(${UTIL_LIB} PUBLIC ${CRYPTOGRAPHY_LIB} ${LOG_LIB} ${CURL_LIBRARIES}) target_link_libraries(${UTIL_LIB} PUBLIC nlohmann_json::nlohmann_json - ghc_filesystem - optional-lite + filesystem date::date ) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index bba571f85..29edc061f 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -16,7 +16,7 @@ #include #include #include -#include "ghc/filesystem.hpp" +#include namespace llarp { @@ -164,7 +164,7 @@ namespace llarp "network", "strict-connect", false, "", AssignmentAcceptor(m_strictConnect)); // TODO: make sure this is documented... what does it mean though? - conf.addUndeclaredHandler("network", [&](string_view, string_view name, string_view value) { + conf.addUndeclaredHandler("network", [&](std::string_view, std::string_view name, std::string_view value) { m_options.emplace(name, value); return true; }); @@ -199,7 +199,7 @@ namespace llarp } LinksConfig::LinkInfo - LinksConfig::LinkInfoFromINIValues(string_view name, string_view value) + LinksConfig::LinkInfoFromINIValues(std::string_view name, std::string_view value) { // we treat the INI k:v pair as: // k: interface name, * indicating outbound @@ -211,8 +211,8 @@ namespace llarp info.addressFamily = AF_INET; info.interface = str(name); - std::vector splits = split(value, ','); - for (string_view str : splits) + std::vector splits = split(value, ','); + for (std::string_view str : splits) { int asNum = std::atoi(str.data()); if (asNum > 0) @@ -233,10 +233,10 @@ namespace llarp conf.defineOption( "bind", "*", false, false, DefaultOutboundLinkValue, [this](std::string arg) { - m_OutboundLink = std::move(LinkInfoFromINIValues("*", arg)); + m_OutboundLink = LinkInfoFromINIValues("*", arg); }); - conf.addUndeclaredHandler("bind", [&](string_view, string_view name, string_view value) { + conf.addUndeclaredHandler("bind", [&](std::string_view, std::string_view name, std::string_view value) { LinkInfo info = LinkInfoFromINIValues(name, value); if (info.port <= 0) @@ -254,7 +254,7 @@ namespace llarp (void)params; conf.addUndeclaredHandler( - "connect", [this](string_view section, string_view name, string_view value) { + "connect", [this](std::string_view section, std::string_view name, std::string_view value) { fs::path file = str(value); if (not fs::exists(file)) throw std::runtime_error(stringify( @@ -277,7 +277,7 @@ namespace llarp (void)params; conf.addUndeclaredHandler( - "services", [this](string_view section, string_view name, string_view value) { + "services", [this](std::string_view section, std::string_view name, std::string_view value) { (void)section; services.emplace_back(name, value); return true; @@ -364,7 +364,7 @@ namespace llarp conf.defineOption( "logging", "level", false, DefaultLogLevel, [this](std::string arg) { - nonstd::optional level = LogLevelFromString(arg); + std::optional level = LogLevelFromString(arg); if (not level.has_value()) throw std::invalid_argument(stringify("invalid log level value: ", arg)); @@ -422,7 +422,7 @@ namespace llarp m_mapAddr = arg; }); - conf.addUndeclaredHandler("snapp", [&](string_view, string_view name, string_view value) { + conf.addUndeclaredHandler("snapp", [&](std::string_view, std::string_view name, std::string_view value) { if (name == "blacklist-snode") { m_snodeBlacklist.push_back(str(value)); @@ -452,7 +452,7 @@ namespace llarp return false; } - parser.IterAll([&](string_view section, const SectionValues_t& values) { + parser.IterAll([&](std::string_view section, const SectionValues_t& values) { for (const auto& pair : values) { conf.addConfigValue(section, pair.first, pair.second); diff --git a/llarp/config/config.hpp b/llarp/config/config.hpp index 6da4a498b..c5579f5cb 100644 --- a/llarp/config/config.hpp +++ b/llarp/config/config.hpp @@ -66,7 +66,7 @@ namespace llarp struct NetworkConfig { - nonstd::optional m_enableProfiling; + std::optional m_enableProfiling; std::string m_routerProfilesFile; std::string m_strictConnect; FreehandOptions m_options; @@ -94,7 +94,7 @@ namespace llarp /// Create a LinkInfo from the given string. /// @throws if str does not represent a LinkInfo. LinkInfo - LinkInfoFromINIValues(string_view name, string_view value); + LinkInfoFromINIValues(std::string_view name, std::string_view value); LinkInfo m_OutboundLink; std::vector m_InboundLinks; diff --git a/llarp/config/definition.cpp b/llarp/config/definition.cpp index af9d907f6..9674c659c 100644 --- a/llarp/config/definition.cpp +++ b/llarp/config/definition.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace llarp { @@ -47,7 +48,7 @@ namespace llarp } ConfigDefinition& - ConfigDefinition::addConfigValue(string_view section, string_view name, string_view value) + ConfigDefinition::addConfigValue(std::string_view section, std::string_view name, std::string_view value) { // see if we have an undeclared handler to fall back to in case section or section:name is // absent @@ -207,7 +208,7 @@ namespace llarp } const OptionDefinition_ptr& - ConfigDefinition::lookupDefinitionOrThrow(string_view section, string_view name) const + ConfigDefinition::lookupDefinitionOrThrow(std::string_view section, std::string_view name) const { const auto sectionItr = m_definitions.find(std::string(section)); if (sectionItr == m_definitions.end()) @@ -222,7 +223,7 @@ namespace llarp } OptionDefinition_ptr& - ConfigDefinition::lookupDefinitionOrThrow(string_view section, string_view name) + ConfigDefinition::lookupDefinitionOrThrow(std::string_view section, std::string_view name) { return const_cast( const_cast(this)->lookupDefinitionOrThrow(section, name)); diff --git a/llarp/config/definition.hpp b/llarp/config/definition.hpp index d72b23e66..4990eb2f4 100644 --- a/llarp/config/definition.hpp +++ b/llarp/config/definition.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include @@ -9,6 +8,9 @@ #include #include #include +#include +#include +#include namespace llarp { @@ -88,7 +90,7 @@ namespace llarp std::string section_, std::string name_, bool required_, - nonstd::optional defaultValue_, + std::optional defaultValue_, std::function acceptor_ = nullptr) : OptionDefinitionBase(section_, name_, required_) , defaultValue(defaultValue_) @@ -102,7 +104,7 @@ namespace llarp std::string name_, bool required_, bool multiValued_, - nonstd::optional defaultValue_, + std::optional defaultValue_, std::function acceptor_ = nullptr) : OptionDefinitionBase(section_, name_, required_, multiValued_) , defaultValue(defaultValue_) @@ -114,7 +116,7 @@ namespace llarp /// option is not required. Otherwise, returns an empty optional. /// /// @return an optional with the parsed value, the default value, or no value. - nonstd::optional + std::optional getValue() const { if (parsedValues.size()) @@ -236,7 +238,7 @@ namespace llarp } } - nonstd::optional defaultValue; + std::optional defaultValue; std::vector parsedValues; std::function acceptor; }; @@ -248,7 +250,7 @@ namespace llarp OptionDefinition::fromString(const std::string& input); using UndeclaredValueHandler = - std::function; + std::function; using OptionDefinition_ptr = std::unique_ptr; @@ -307,7 +309,7 @@ namespace llarp /// @return `*this` for chaining calls /// @throws if the option doesn't exist or the provided string isn't parseable ConfigDefinition& - addConfigValue(string_view section, string_view name, string_view value); + addConfigValue(std::string_view section, std::string_view name, std::string_view value); /// Get a config value. If the value hasn't been provided but a default has, the default will /// be returned. If no value and no default is provided, an empty optional will be returned. @@ -321,8 +323,8 @@ namespace llarp /// @throws std::invalid_argument if there is no such config option or the wrong type T was // provided template - nonstd::optional - getConfigValue(string_view section, string_view name) + std::optional + getConfigValue(std::string_view section, std::string_view name) { OptionDefinition_ptr& definition = lookupDefinitionOrThrow(section, name); @@ -402,9 +404,9 @@ namespace llarp private: OptionDefinition_ptr& - lookupDefinitionOrThrow(string_view section, string_view name); + lookupDefinitionOrThrow(std::string_view section, std::string_view name); const OptionDefinition_ptr& - lookupDefinitionOrThrow(string_view section, string_view name) const; + lookupDefinitionOrThrow(std::string_view section, std::string_view name) const; using SectionVisitor = std::function; void diff --git a/llarp/config/ini.cpp b/llarp/config/ini.cpp index 694b6ff3b..9c1028e08 100644 --- a/llarp/config/ini.cpp +++ b/llarp/config/ini.cpp @@ -12,7 +12,7 @@ namespace llarp { bool - ConfigParser::LoadFile(string_view fname) + ConfigParser::LoadFile(std::string_view fname) { std::string name{fname}; { @@ -31,7 +31,7 @@ namespace llarp } bool - ConfigParser::LoadFromStr(string_view str) + ConfigParser::LoadFromStr(std::string_view str) { m_Data.resize(str.size()); std::copy(str.begin(), str.end(), m_Data.begin()); @@ -55,7 +55,7 @@ namespace llarp bool ConfigParser::Parse() { - std::list lines; + std::list lines; { auto itr = m_Data.begin(); // split into lines @@ -71,16 +71,16 @@ namespace llarp } } - string_view sectName; + std::string_view sectName; size_t lineno = 0; for (const auto& line : lines) { lineno++; - string_view realLine; + std::string_view realLine; auto comment = line.find_first_of(';'); - if (comment == string_view::npos) + if (comment == std::string_view::npos) comment = line.find_first_of('#'); - if (comment == string_view::npos) + if (comment == std::string_view::npos) realLine = line; else realLine = line.substr(0, comment); @@ -91,8 +91,8 @@ namespace llarp auto sectOpenPos = realLine.find_first_of('['); auto sectClosPos = realLine.find_first_of(']'); auto kvDelim = realLine.find_first_of('='); - if (sectOpenPos != string_view::npos && sectClosPos != string_view::npos - && kvDelim == string_view::npos) + if (sectOpenPos != std::string_view::npos && sectClosPos != std::string_view::npos + && kvDelim == std::string_view::npos) { // section header @@ -106,13 +106,13 @@ namespace llarp // set section name sectName = realLine.substr(sectOpenPos, sectClosPos); } - else if (kvDelim != string_view::npos) + else if (kvDelim != std::string_view::npos) { // key value pair - string_view::size_type k_start = 0; - string_view::size_type k_end = kvDelim; - string_view::size_type v_start = kvDelim + 1; - string_view::size_type v_end = realLine.size() - 1; + std::string_view::size_type k_start = 0; + std::string_view::size_type k_end = kvDelim; + std::string_view::size_type v_start = kvDelim + 1; + std::string_view::size_type v_end = realLine.size() - 1; // clamp whitespaces while (whitespace(realLine[k_start]) && k_start != kvDelim) ++k_start; @@ -124,8 +124,8 @@ namespace llarp --v_end; // sect.k = v - string_view k = realLine.substr(k_start, k_end - k_start); - string_view v = realLine.substr(v_start, 1 + (v_end - v_start)); + std::string_view k = realLine.substr(k_start, k_end - k_start); + std::string_view v = realLine.substr(v_start, 1 + (v_end - v_start)); if (k.size() == 0 || v.size() == 0) { LogError(m_FileName, " invalid line (", lineno, "): '", line, "'"); @@ -145,7 +145,7 @@ namespace llarp } void - ConfigParser::IterAll(std::function visit) + ConfigParser::IterAll(std::function visit) { for (const auto& item : m_Config) visit(item.first, item.second); diff --git a/llarp/config/ini.hpp b/llarp/config/ini.hpp index 28cad23a1..774afe04a 100644 --- a/llarp/config/ini.hpp +++ b/llarp/config/ini.hpp @@ -1,8 +1,7 @@ #ifndef LOKINET_BOOTSERV_CONFIG_HPP #define LOKINET_BOOTSERV_CONFIG_HPP -#include - +#include #include #include #include @@ -22,17 +21,17 @@ namespace llarp /// return true on success /// return false on error bool - LoadFile(string_view fname); + LoadFile(std::string_view fname); /// load from string /// return true on success /// return false on error bool - LoadFromStr(string_view str); + LoadFromStr(std::string_view str); /// iterate all sections and thier values void - IterAll(std::function visit); + IterAll(std::function visit); /// visit a section in config read only by name /// return false if no section or value propagated from visitor diff --git a/llarp/context.cpp b/llarp/context.cpp index fea9d92a0..43ec511a0 100644 --- a/llarp/context.cpp +++ b/llarp/context.cpp @@ -28,7 +28,7 @@ namespace llarp } bool - Context::Configure(bool isRelay, nonstd::optional dataDir) + Context::Configure(bool isRelay, std::optional dataDir) { fs::path defaultDataDir = dataDir.has_value() ? dataDir.value() : GetDefaultDataDir(); diff --git a/llarp/dht/context.cpp b/llarp/dht/context.cpp index c6cdb376e..d579b92c3 100644 --- a/llarp/dht/context.cpp +++ b/llarp/dht/context.cpp @@ -157,7 +157,7 @@ namespace llarp Init(const Key_t& us, AbstractRouter* router) override; /// get localally stored introset by service address - nonstd::optional + std::optional GetIntroSetByLocation(const Key_t& location) const override; void @@ -412,7 +412,7 @@ namespace llarp } } - nonstd::optional + std::optional Context::GetIntroSetByLocation(const Key_t& key) const { auto itr = _services->nodes.find(key); diff --git a/llarp/dht/context.hpp b/llarp/dht/context.hpp index 3f0febb72..ce88f3935 100644 --- a/llarp/dht/context.hpp +++ b/llarp/dht/context.hpp @@ -132,7 +132,7 @@ namespace llarp virtual void Init(const Key_t& us, AbstractRouter* router) = 0; - virtual nonstd::optional + virtual std::optional GetIntroSetByLocation(const Key_t& location) const = 0; virtual llarp_time_t diff --git a/llarp/dht/messages/gotintro.hpp b/llarp/dht/messages/gotintro.hpp index 8001e15dc..5c4a69277 100644 --- a/llarp/dht/messages/gotintro.hpp +++ b/llarp/dht/messages/gotintro.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include namespace llarp { @@ -20,7 +20,7 @@ namespace llarp /// txid uint64_t txid = 0; /// the key of a router closer in keyspace if iterative lookup - nonstd::optional closer; + std::optional closer; GotIntroMessage(const Key_t& from) : IMessage(from) { diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index 2c706cb31..f21e4b83a 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/llarp/ev/ev.cpp b/llarp/ev/ev.cpp index 944668617..8d83c3303 100644 --- a/llarp/ev/ev.cpp +++ b/llarp/ev/ev.cpp @@ -1,11 +1,11 @@ #include #include -#include #include #include #include #include +#include // We libuv now #include @@ -144,7 +144,7 @@ void llarp_tcp_async_try_connect(struct llarp_ev_loop* loop, struct llarp_tcp_connecter* tcp) { tcp->loop = loop; - llarp::string_view addr_str, port_str; + std::string_view addr_str, port_str; // try parsing address const char* begin = tcp->remote; const char* ptr = strstr(tcp->remote, ":"); @@ -162,9 +162,9 @@ llarp_tcp_async_try_connect(struct llarp_ev_loop* loop, struct llarp_tcp_connect { ++end; } - addr_str = llarp::string_view(begin, ptr - begin); + addr_str = std::string_view(begin, ptr - begin); ++ptr; - port_str = llarp::string_view(ptr, end - ptr); + port_str = std::string_view(ptr, end - ptr); // actually parse address llarp::Addr addr(addr_str, port_str); diff --git a/llarp/link/factory.cpp b/llarp/link/factory.cpp index 8a8f5b2a6..74c959598 100644 --- a/llarp/link/factory.cpp +++ b/llarp/link/factory.cpp @@ -4,7 +4,7 @@ namespace llarp { LinkFactory::LinkType - LinkFactory::TypeFromName(string_view str) + LinkFactory::TypeFromName(std::string_view str) { if (str == "iwp") return LinkType::eLinkIWP; @@ -40,4 +40,4 @@ namespace llarp return nullptr; } } -} // namespace llarp \ No newline at end of file +} // namespace llarp diff --git a/llarp/link/factory.hpp b/llarp/link/factory.hpp index bf1110f73..905fc8680 100644 --- a/llarp/link/factory.hpp +++ b/llarp/link/factory.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_LINK_FACTORY_HPP #define LLARP_LINK_FACTORY_HPP -#include #include +#include #include #include @@ -35,7 +35,7 @@ namespace llarp /// get link type by name string /// if invalid returns eLinkUnspec static LinkType - TypeFromName(string_view name); + TypeFromName(std::string_view name); /// turns a link type into a string representation static std::string @@ -48,4 +48,4 @@ namespace llarp } // namespace llarp -#endif \ No newline at end of file +#endif diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 593b0c961..195d59629 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include namespace llarp { @@ -185,7 +185,7 @@ namespace llarp // the actual hop std::shared_ptr hop; - const nonstd::optional fromAddr; + const std::optional fromAddr; LRCMFrameDecrypt(Context* ctx, Decrypter_ptr dec, const LR_CommitMessage* commit) : decrypter(std::move(dec)) @@ -194,7 +194,7 @@ namespace llarp , hop(std::make_shared()) , fromAddr( commit->session->GetRemoteRC().IsPublicRouter() - ? nonstd::optional{} + ? std::optional{} : commit->session->GetRemoteEndpoint()) { hop->info.downstream = commit->session->GetPubKey(); diff --git a/llarp/net/net.hpp b/llarp/net/net.hpp index aa6bb5c5a..5192a628f 100644 --- a/llarp/net/net.hpp +++ b/llarp/net/net.hpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/llarp/net/net_addr.cpp b/llarp/net/net_addr.cpp index 7df970959..ab8c647ee 100644 --- a/llarp/net/net_addr.cpp +++ b/llarp/net/net_addr.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include // for addrinfo #ifndef _WIN32 @@ -59,26 +59,26 @@ namespace llarp return (const in_addr*)&_addr.sin6_addr.s6_addr[12]; } - Addr::Addr(string_view str) : Addr() + Addr::Addr(std::string_view str) : Addr() { this->from_char_array(str); } - Addr::Addr(string_view str, const uint16_t p_port) : Addr(str) + Addr::Addr(std::string_view str, const uint16_t p_port) : Addr(str) { this->port(p_port); } - Addr::Addr(string_view addr_str, string_view port_str) + Addr::Addr(std::string_view addr_str, std::string_view port_str) : Addr(addr_str, std::strtoul(port_str.data(), nullptr, 10)) { } bool - Addr::from_char_array(string_view in) + Addr::from_char_array(std::string_view in) { auto pPosition = in.find(':'); - if (pPosition != string_view::npos) + if (pPosition != std::string_view::npos) { // parse port uint16_t port = std::atoi(std::string(in.begin() + pPosition + 1, in.end()).c_str()); @@ -94,7 +94,7 @@ namespace llarp hint.ai_family = PF_UNSPEC; hint.ai_flags = AI_NUMERICHOST; - if (pPosition != string_view::npos) + if (pPosition != std::string_view::npos) { ret = getaddrinfo( std::string(in.begin(), in.begin() + pPosition).c_str(), nullptr, &hint, &res); diff --git a/llarp/net/net_addr.hpp b/llarp/net/net_addr.hpp index 5fb820811..4958c540b 100644 --- a/llarp/net/net_addr.hpp +++ b/llarp/net/net_addr.hpp @@ -4,9 +4,9 @@ #include #include #include -#include #include +#include #include namespace llarp @@ -21,11 +21,11 @@ namespace llarp Addr(); - Addr(string_view str); + Addr(std::string_view str); - Addr(string_view str, const uint16_t p_port); + Addr(std::string_view str, const uint16_t p_port); - Addr(string_view addr_str, string_view port_str); + Addr(std::string_view addr_str, std::string_view port_str); void port(uint16_t port); @@ -43,7 +43,7 @@ namespace llarp addr4() const; bool - from_char_array(string_view str); + from_char_array(std::string_view str); bool from_4int(const uint8_t one, const uint8_t two, const uint8_t three, const uint8_t four); diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index b6daf0572..e00bccdb9 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -142,7 +142,7 @@ namespace llarp uint64_t currentStatus = status; size_t index = 0; - nonstd::optional failedAt; + std::optional failedAt; while (index < hops.size()) { if (!frames[index].DoDecrypt(hops[index].shared)) diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 4287ab7b8..3abb7b265 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -1259,7 +1259,7 @@ namespace llarp } bool - Router::LoadHiddenServiceConfig(string_view fname) + Router::LoadHiddenServiceConfig(std::string_view fname) { LogDebug("opening hidden service config ", fname); service::Config conf; diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index 3474a1d36..920ee4c5c 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -334,7 +334,7 @@ namespace llarp Close(); bool - LoadHiddenServiceConfig(string_view fname); + LoadHiddenServiceConfig(std::string_view fname); bool AddHiddenService(const service::Config::section_t& config); diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 3b0248aae..d90f2389c 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -163,7 +163,7 @@ namespace llarp nickname.Zero(); enckey.Zero(); pubkey.Zero(); - routerVersion = nonstd::optional{}; + routerVersion = std::optional{}; last_updated = 0s; } @@ -258,7 +258,7 @@ namespace llarp } void - RouterContact::SetNick(string_view nick) + RouterContact::SetNick(std::string_view nick) { nickname.Zero(); std::copy( diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index 797f7e058..c658ee156 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -105,7 +105,7 @@ namespace llarp llarp_time_t last_updated = 0s; uint64_t version = LLARP_PROTO_VERSION; - nonstd::optional routerVersion; + std::optional routerVersion; util::StatusObject ExtractStatus() const; @@ -174,7 +174,7 @@ namespace llarp IsPublicRouter() const; void - SetNick(string_view nick); + SetNick(std::string_view nick); bool Verify(llarp_time_t now, bool allowExpired = true) const; diff --git a/llarp/service/config.cpp b/llarp/service/config.cpp index 7df8ce1f6..c9ad23171 100644 --- a/llarp/service/config.cpp +++ b/llarp/service/config.cpp @@ -7,12 +7,12 @@ namespace llarp namespace service { bool - Config::Load(string_view fname) + Config::Load(std::string_view fname) { ConfigParser parser; if (!parser.LoadFile(fname)) return false; - parser.IterAll([&](string_view name, const ConfigParser::SectionValues_t& section) { + parser.IterAll([&](std::string_view name, const ConfigParser::SectionValues_t& section) { Config::section_t values; values.first.assign(name.begin(), name.end()); for (const auto& item : section) diff --git a/llarp/service/config.hpp b/llarp/service/config.hpp index 3f1074f8a..a0a96a4e4 100644 --- a/llarp/service/config.hpp +++ b/llarp/service/config.hpp @@ -1,10 +1,9 @@ #ifndef LLARP_SERVICE_CONFIG_HPP #define LLARP_SERVICE_CONFIG_HPP -#include - #include #include +#include namespace llarp { @@ -18,7 +17,7 @@ namespace llarp std::list services; bool - Load(string_view fname); + Load(std::string_view fname); }; } // namespace service } // namespace llarp diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index c272cb5cb..80f2a65ef 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -941,7 +941,7 @@ namespace llarp bool Endpoint::OnLookup( - const Address& addr, nonstd::optional introset, const RouterID& endpoint) + const Address& addr, std::optional introset, const RouterID& endpoint) { const auto now = Router()->Now(); auto& fails = m_state->m_ServiceLookupFails; diff --git a/llarp/service/endpoint.hpp b/llarp/service/endpoint.hpp index 2a2dc0077..6bb600724 100644 --- a/llarp/service/endpoint.hpp +++ b/llarp/service/endpoint.hpp @@ -402,7 +402,7 @@ namespace llarp bool OnLookup( const service::Address& addr, - nonstd::optional i, + std::optional i, const RouterID& endpoint); /* */ bool diff --git a/llarp/service/hidden_service_address_lookup.cpp b/llarp/service/hidden_service_address_lookup.cpp index 6edeb942f..6923cdafb 100644 --- a/llarp/service/hidden_service_address_lookup.cpp +++ b/llarp/service/hidden_service_address_lookup.cpp @@ -26,7 +26,7 @@ namespace llarp bool HiddenServiceAddressLookup::HandleResponse(const std::set& results) { - nonstd::optional found; + std::optional found; const Address remote(rootkey); LogInfo("found ", results.size(), " for ", remote.ToString()); if (results.size() > 0) diff --git a/llarp/service/hidden_service_address_lookup.hpp b/llarp/service/hidden_service_address_lookup.hpp index 50140404d..761ac11e0 100644 --- a/llarp/service/hidden_service_address_lookup.hpp +++ b/llarp/service/hidden_service_address_lookup.hpp @@ -16,7 +16,7 @@ namespace llarp uint64_t relayOrder; const dht::Key_t location; using HandlerFunc = - std::function, const RouterID&)>; + std::function, const RouterID&)>; HandlerFunc handle; HiddenServiceAddressLookup( diff --git a/llarp/service/identity.cpp b/llarp/service/identity.cpp index a791ffe6d..2ba0fe332 100644 --- a/llarp/service/identity.cpp +++ b/llarp/service/identity.cpp @@ -152,7 +152,7 @@ namespace llarp return crypto->derive_subkey_private(derivedSignKey, signkey, 1); } - nonstd::optional + std::optional Identity::EncryptAndSignIntroSet(const IntroSet& other_i, llarp_time_t now) const { EncryptedIntroSet encrypted; diff --git a/llarp/service/identity.hpp b/llarp/service/identity.hpp index 1185aa42c..d1d4487b9 100644 --- a/llarp/service/identity.hpp +++ b/llarp/service/identity.hpp @@ -50,7 +50,7 @@ namespace llarp bool DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf); - nonstd::optional + std::optional EncryptAndSignIntroSet(const IntroSet& i, llarp_time_t now) const; bool diff --git a/llarp/service/info.hpp b/llarp/service/info.hpp index ab619bdf7..e4ada7146 100644 --- a/llarp/service/info.hpp +++ b/llarp/service/info.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include namespace llarp { @@ -23,7 +23,7 @@ namespace llarp VanityNonce vanity; uint64_t version = LLARP_PROTO_VERSION; - using OptNonce = nonstd::optional; + using OptNonce = std::optional; void RandomizeVanity() diff --git a/llarp/service/intro_set.cpp b/llarp/service/intro_set.cpp index 4e4e6cebc..83f4cf558 100644 --- a/llarp/service/intro_set.cpp +++ b/llarp/service/intro_set.cpp @@ -82,7 +82,7 @@ namespace llarp return out; } - nonstd::optional + std::optional EncryptedIntroSet::MaybeDecrypt(const PubKey& root) const { SharedSecret k(root); diff --git a/llarp/service/intro_set.hpp b/llarp/service/intro_set.hpp index b15b6bd77..69338ea84 100644 --- a/llarp/service/intro_set.hpp +++ b/llarp/service/intro_set.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ namespace llarp PQPubKey K; Tag topic; llarp_time_t T = 0s; - nonstd::optional W; + std::optional W; Signature Z; uint64_t version = LLARP_PROTO_VERSION; @@ -109,7 +109,7 @@ namespace llarp llarp_time_t signedAt = 0s; Payload_t introsetPayload; TunnelNonce nounce; - nonstd::optional topic; + std::optional topic; Signature sig; bool @@ -143,7 +143,7 @@ namespace llarp util::StatusObject ExtractStatus() const; - nonstd::optional + std::optional MaybeDecrypt(const PubKey& rootKey) const; }; diff --git a/llarp/service/outbound_context.cpp b/llarp/service/outbound_context.cpp index d4549d43b..759f7a5aa 100644 --- a/llarp/service/outbound_context.cpp +++ b/llarp/service/outbound_context.cpp @@ -85,7 +85,7 @@ namespace llarp bool OutboundContext::OnIntroSetUpdate( - const Address&, nonstd::optional foundIntro, const RouterID& endpoint) + const Address&, std::optional foundIntro, const RouterID& endpoint) { if (markedBad) return true; diff --git a/llarp/service/outbound_context.hpp b/llarp/service/outbound_context.hpp index d30cf04f2..03a79406c 100644 --- a/llarp/service/outbound_context.hpp +++ b/llarp/service/outbound_context.hpp @@ -118,7 +118,7 @@ namespace llarp OnGeneratedIntroFrame(AsyncKeyExchange* k, PathID_t p); bool - OnIntroSetUpdate(const Address& addr, nonstd::optional i, const RouterID& endpoint); + OnIntroSetUpdate(const Address& addr, std::optional i, const RouterID& endpoint); const dht::Key_t location; uint64_t m_UpdateIntrosetTX = 0; diff --git a/llarp/util/fs.hpp b/llarp/util/fs.hpp index 40ab0a052..132e5f132 100644 --- a/llarp/util/fs.hpp +++ b/llarp/util/fs.hpp @@ -9,14 +9,14 @@ #define PATH_SEP "/" #endif -#include -namespace fs = ghc::filesystem; +#include +namespace fs = std::filesystem; #ifndef _MSC_VER #include #endif -#include +#include namespace llarp { @@ -32,7 +32,7 @@ namespace llarp /// open a stream to a file and ensure it exists before open /// sets any permissions on creation template - nonstd::optional + std::optional OpenFileStream(fs::path pathname, std::ios::openmode mode) { if (EnsurePrivateFile(pathname)) diff --git a/llarp/util/json.cpp b/llarp/util/json.cpp index 7b0145d57..6c77f63ef 100644 --- a/llarp/util/json.cpp +++ b/llarp/util/json.cpp @@ -1,5 +1,4 @@ #include -#include #include #include diff --git a/llarp/util/json.hpp b/llarp/util/json.hpp index a9b8b8571..ea4cda5a6 100644 --- a/llarp/util/json.hpp +++ b/llarp/util/json.hpp @@ -1,8 +1,6 @@ #ifndef LLARP_UTIL_JSON_HPP #define LLARP_UTIL_JSON_HPP -#include - #include #include diff --git a/llarp/util/logging/loglevel.cpp b/llarp/util/logging/loglevel.cpp index 5810a1e1e..eda0f88fd 100644 --- a/llarp/util/logging/loglevel.cpp +++ b/llarp/util/logging/loglevel.cpp @@ -46,7 +46,7 @@ namespace llarp } } - nonstd::optional + std::optional LogLevelFromString(std::string level) { std::transform(level.begin(), level.end(), level.begin(), [](const unsigned char ch) -> char { diff --git a/llarp/util/logging/loglevel.hpp b/llarp/util/logging/loglevel.hpp index 24e393c4c..eab3982fb 100644 --- a/llarp/util/logging/loglevel.hpp +++ b/llarp/util/logging/loglevel.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_UTIL_LOG_LEVEL_HPP #define LLARP_UTIL_LOG_LEVEL_HPP #include -#include +#include namespace llarp { @@ -22,7 +22,7 @@ namespace llarp std::string LogLevelToName(LogLevel lvl); - nonstd::optional + std::optional LogLevelFromString(std::string level); } // namespace llarp diff --git a/llarp/util/printer.cpp b/llarp/util/printer.cpp index 57d629282..a4e56f487 100644 --- a/llarp/util/printer.cpp +++ b/llarp/util/printer.cpp @@ -59,7 +59,7 @@ namespace llarp } void - Printer::printHexAddr(string_view name, const void* address) const + Printer::printHexAddr(std::string_view name, const void* address) const { printIndent(); m_stream << name << " = "; @@ -182,7 +182,7 @@ namespace llarp void PrintHelper::printType( std::ostream& stream, - const string_view& value, + const std::string_view& value, int, int spacesPerLevel, traits::select::Case) diff --git a/llarp/util/printer.hpp b/llarp/util/printer.hpp index 7954fa2a7..8c649af1d 100644 --- a/llarp/util/printer.hpp +++ b/llarp/util/printer.hpp @@ -1,13 +1,13 @@ #ifndef LLARP_PRINTER_HPP #define LLARP_PRINTER_HPP -#include #include #include #include #include #include +#include namespace llarp { @@ -57,7 +57,7 @@ namespace llarp /// - If `Type` is a `void *`, `const void *` or function pointer, and not /// null, print in hex format or print "null". /// - If `Type` is a `char *`, a `const char *`, a C-style char array, a - /// `std::string` or `llarp::string_view` print the string wrapped in `"`. + /// `std::string` or `std::string_view` print the string wrapped in `"`. /// - If `Type` is a pointer type, print the pointer, followed by the value /// if not-null. /// - If `Type` is a pair/tuple type, print the elements of the tuple. @@ -66,15 +66,15 @@ namespace llarp /// - If `Type` is any other type, call the `print` method on that type. template void - printAttribute(string_view name, const Type& value) const; + printAttribute(std::string_view name, const Type& value) const; template void - printAttributeAsHex(string_view name, const Type& value) const; + printAttributeAsHex(std::string_view name, const Type& value) const; template void - printAttribute(string_view name, const InputIt& begin, const InputIt& end) const; + printAttribute(std::string_view name, const InputIt& begin, const InputIt& end) const; template void @@ -87,20 +87,20 @@ namespace llarp template void printForeignAttribute( - string_view name, const Type& value, const PrintFunction& printFunction) const; + std::string_view name, const Type& value, const PrintFunction& printFunction) const; template void printForeignValue(const Type& value, const PrintFunction& printFunction) const; void - printHexAddr(string_view name, const void* address) const; + printHexAddr(std::string_view name, const void* address) const; void printHexAddr(const void* address) const; template void - printOrNull(string_view name, const Type& address) const; + printOrNull(std::string_view name, const Type& address) const; template void printOrNull(const Type& address) const; @@ -215,7 +215,7 @@ namespace llarp static void printType( std::ostream& stream, - const string_view& value, + const std::string_view& value, int level, int spaces, traits::select::Case); @@ -257,7 +257,7 @@ namespace llarp template inline void - Printer::printAttribute(string_view name, const Type& value) const + Printer::printAttribute(std::string_view name, const Type& value) const { assert(!name.empty()); printIndent(); @@ -269,7 +269,7 @@ namespace llarp template inline void - Printer::printAttributeAsHex(string_view name, const Type& value) const + Printer::printAttributeAsHex(std::string_view name, const Type& value) const { static_assert(std::is_integral::value, "type should be integral"); assert(!name.empty()); @@ -289,7 +289,7 @@ namespace llarp template inline void - Printer::printAttribute(string_view name, const InputIt& begin, const InputIt& end) const + Printer::printAttribute(std::string_view name, const InputIt& begin, const InputIt& end) const { assert(!name.empty()); printIndent(); @@ -320,7 +320,7 @@ namespace llarp template inline void Printer::printForeignAttribute( - string_view name, const Type& value, const PrintFunction& printFunction) const + std::string_view name, const Type& value, const PrintFunction& printFunction) const { assert(!name.empty()); printIndent(); @@ -341,7 +341,7 @@ namespace llarp template inline void - Printer::printOrNull(string_view name, const Type& address) const + Printer::printOrNull(std::string_view name, const Type& address) const { assert(!name.empty()); printIndent(); @@ -385,7 +385,7 @@ namespace llarp template <> inline void - Printer::printOrNull(string_view name, const void* const& address) const + Printer::printOrNull(std::string_view name, const void* const& address) const { assert(!name.empty()); printIndent(); @@ -397,7 +397,7 @@ namespace llarp } template <> inline void - Printer::printOrNull(string_view name, void* const& address) const + Printer::printOrNull(std::string_view name, void* const& address) const { const void* const& temp = address; diff --git a/llarp/util/status.hpp b/llarp/util/status.hpp index bb38ca836..3af0cd4fd 100644 --- a/llarp/util/status.hpp +++ b/llarp/util/status.hpp @@ -1,14 +1,8 @@ #ifndef LLARP_UTIL_STATUS_HPP #define LLARP_UTIL_STATUS_HPP -#include - #include -#include -#include -#include - namespace llarp { namespace util diff --git a/llarp/util/str.cpp b/llarp/util/str.cpp index 83462ff06..8024437ad 100644 --- a/llarp/util/str.cpp +++ b/llarp/util/str.cpp @@ -9,7 +9,7 @@ namespace llarp { bool - CaselessLessThan::operator()(string_view lhs, string_view rhs) const + CaselessLessThan::operator()(std::string_view lhs, std::string_view rhs) const { const size_t s = std::min(lhs.size(), rhs.size()); for (size_t i = 0; i < s; ++i) @@ -31,17 +31,17 @@ namespace llarp } bool - IsFalseValue(string_view str) + IsFalseValue(std::string_view str) { - static const std::set vals{"no", "false", "0", "off"}; + static const std::set vals{"no", "false", "0", "off"}; return vals.count(str) > 0; } bool - IsTrueValue(string_view str) + IsTrueValue(std::string_view str) { - static const std::set vals{"yes", "true", "1", "on"}; + static const std::set vals{"yes", "true", "1", "on"}; return vals.count(str) > 0; } @@ -61,11 +61,11 @@ namespace llarp constexpr static char whitespace[] = " \t\n\r\f\v"; - string_view - TrimWhitespace(string_view str) + std::string_view + TrimWhitespace(std::string_view str) { size_t begin = str.find_first_not_of(whitespace); - if (begin == string_view::npos) + if (begin == std::string_view::npos) { str.remove_prefix(str.size()); return str; @@ -73,20 +73,20 @@ namespace llarp str.remove_prefix(begin); size_t end = str.find_last_not_of(whitespace); - if (end != string_view::npos) + if (end != std::string_view::npos) str.remove_suffix(str.size() - end - 1); return str; } - std::vector - split(string_view str, char delimiter) + std::vector + split(std::string_view str, char delimiter) { - std::vector splits; + std::vector splits; size_t last = 0; size_t next = 0; - while (last < str.size() and next < string_view::npos) + while (last < str.size() and next < std::string_view::npos) { next = str.find_first_of(delimiter, last); if (next > last) diff --git a/llarp/util/str.hpp b/llarp/util/str.hpp index 6677ec3cf..394819674 100644 --- a/llarp/util/str.hpp +++ b/llarp/util/str.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_STR_HPP #define LLARP_STR_HPP -#include +#include #include #include @@ -11,24 +11,24 @@ namespace llarp StrEq(const char* s1, const char* s2); bool - IsFalseValue(string_view str); + IsFalseValue(std::string_view str); struct CaselessLessThan { bool - operator()(string_view lhs, string_view rhs) const; + operator()(std::string_view lhs, std::string_view rhs) const; }; bool - IsTrueValue(string_view str); + IsTrueValue(std::string_view str); /// Trim leading and trailing (ascii) whitespace from the given string; - /// returns a string_view of the trimmed part of the string. + /// returns a std::string_view of the trimmed part of the string. #ifdef __GNUG__ [[gnu::warn_unused_result]] #endif - string_view - TrimWhitespace(string_view str); + std::string_view + TrimWhitespace(std::string_view str); template std::string @@ -43,13 +43,19 @@ namespace llarp return o.str(); } + // Shortcut for explicitly casting a string_view to a string. Saves 8 characters compared to + // `std::string(view)`. + inline std::string str(std::string_view s) { + return std::string{s}; + } + /// Split a string on a given delimiter // /// @param str is the string to split /// @param delimiter is the character to split on - /// @return a vector of string_views with the split words, excluding the delimeter - std::vector - split(string_view str, char delimiter); + /// @return a vector of std::string_views with the split words, excluding the delimeter + std::vector + split(std::string_view str, char delimiter); } // namespace llarp diff --git a/llarp/util/string_view.hpp b/llarp/util/string_view.hpp deleted file mode 100644 index fd2266346..000000000 --- a/llarp/util/string_view.hpp +++ /dev/null @@ -1,231 +0,0 @@ -#ifndef LLARP_STRING_VIEW_HPP -#define LLARP_STRING_VIEW_HPP - -// Copied from loki-mq (with namespaces modified); when we fully import loki-mq -// we can just use it directly. - -// To keep this identical to loki-mq's copy (e.g. to be able to diff it): -// -// clang-format off - -#include - -#ifdef __cpp_lib_string_view - -#include -namespace llarp { using string_view = std::string_view; } - -#else - -#include -#include - -namespace llarp { - -/// Basic implementation of std::string_view (except for std::hash support). -class simple_string_view { - const char *data_; - size_t size_; -public: - using traits_type = std::char_traits; - using value_type = char; - using pointer = char*; - using const_pointer = const char*; - using reference = char&; - using const_reference = const char&; - using const_iterator = const_pointer; - using iterator = const_iterator; - using const_reverse_iterator = std::reverse_iterator; - using reverse_iterator = const_reverse_iterator; - using size_type = std::size_t; - using different_type = std::ptrdiff_t; - - static constexpr auto& npos = std::string::npos; - - constexpr simple_string_view() noexcept : data_{nullptr}, size_{0} {} - constexpr simple_string_view(const simple_string_view&) noexcept = default; - simple_string_view(const std::string& str) : data_{str.data()}, size_{str.size()} {} - constexpr simple_string_view(const char* data, size_t size) noexcept : data_{data}, size_{size} {} - simple_string_view(const char* data) : data_{data}, size_{traits_type::length(data)} {} - simple_string_view& operator=(const simple_string_view&) = default; - constexpr const char* data() const noexcept { return data_; } - constexpr size_t size() const noexcept { return size_; } - constexpr size_t length() const noexcept { return size_; } - constexpr size_t max_size() const noexcept { return std::numeric_limits::max(); } - constexpr bool empty() const noexcept { return size_ == 0; } - explicit operator std::string() const { return {data_, size_}; } - constexpr const char* begin() const noexcept { return data_; } - constexpr const char* cbegin() const noexcept { return data_; } - constexpr const char* end() const noexcept { return data_ + size_; } - constexpr const char* cend() const noexcept { return data_ + size_; } - reverse_iterator rbegin() const { return reverse_iterator{end()}; } - reverse_iterator crbegin() const { return reverse_iterator{end()}; } - reverse_iterator rend() const { return reverse_iterator{begin()}; } - reverse_iterator crend() const { return reverse_iterator{begin()}; } - constexpr const char& operator[](size_t pos) const { return data_[pos]; } - constexpr const char& front() const { return *data_; } - constexpr const char& back() const { return data_[size_ - 1]; } - int compare(simple_string_view s) const; - constexpr void remove_prefix(size_t n) { data_ += n; size_ -= n; } - constexpr void remove_suffix(size_t n) { size_ -= n; } - void swap(simple_string_view &s) noexcept { std::swap(data_, s.data_); std::swap(size_, s.size_); } - -#if defined(__clang__) || !defined(__GNUG__) || __GNUC__ >= 6 - constexpr // GCC 5.x is buggy wrt constexpr throwing -#endif - const char& at(size_t pos) const { - if (pos >= size()) - throw std::out_of_range{"invalid string_view index"}; - return data_[pos]; - }; - - size_t copy(char* dest, size_t count, size_t pos = 0) const { - if (pos > size()) throw std::out_of_range{"invalid copy pos"}; - size_t rcount = std::min(count, size_ - pos); - traits_type::copy(dest, data_ + pos, rcount); - return rcount; - } - -#if defined(__clang__) || !defined(__GNUG__) || __GNUC__ >= 6 - constexpr // GCC 5.x is buggy wrt constexpr throwing -#endif - simple_string_view substr(size_t pos = 0, size_t count = npos) const { - if (pos > size()) throw std::out_of_range{"invalid substr range"}; - simple_string_view result = *this; - if (pos > 0) result.remove_prefix(pos); - if (count < result.size()) result.remove_suffix(result.size() - count); - return result; - } - - size_t find(simple_string_view v, size_t pos = 0) const { - if (pos > size_ || v.size_ > size_) return npos; - for (const size_t max_pos = size_ - v.size_; pos <= max_pos; ++pos) { - if (0 == traits_type::compare(v.data_, data_ + pos, v.size_)) - return pos; - } - return npos; - } - size_t find(char c, size_t pos = 0) const { return find({&c, 1}, pos); } - size_t find(const char* c, size_t pos, size_t count) const { return find({c, count}, pos); } - size_t find(const char* c, size_t pos = 0) const { return find(simple_string_view(c), pos); } - - size_t rfind(simple_string_view v, size_t pos = npos) const { - if (v.size_ > size_) return npos; - const size_t max_pos = size_ - v.size_; - for (pos = std::min(pos, max_pos); pos <= max_pos; --pos) { - if (0 == traits_type::compare(v.data_, data_ + pos, v.size_)) - return pos; - } - return npos; - } - size_t rfind(char c, size_t pos = npos) const { return rfind({&c, 1}, pos); } - size_t rfind(const char* c, size_t pos, size_t count) const { return rfind({c, count}, pos); } - size_t rfind(const char* c, size_t pos = npos) const { return rfind(simple_string_view(c), pos); } - - constexpr size_t find_first_of(simple_string_view v, size_t pos = 0) const noexcept { - for (; pos < size_; ++pos) - for (char c : v) - if (data_[pos] == c) - return pos; - return npos; - } - constexpr size_t find_first_of(char c, size_t pos = 0) const noexcept { return find_first_of({&c, 1}, pos); } - constexpr size_t find_first_of(const char* c, size_t pos, size_t count) const { return find_first_of({c, count}, pos); } - size_t find_first_of(const char* c, size_t pos = 0) const { return find_first_of(simple_string_view(c), pos); } - - constexpr size_t find_last_of(simple_string_view v, const size_t pos = npos) const noexcept { - if (size_ == 0) return npos; - const size_t last_pos = std::min(pos, size_-1); - for (size_t i = last_pos; i <= last_pos; --i) - for (char c : v) - if (data_[i] == c) - return i; - return npos; - } - constexpr size_t find_last_of(char c, size_t pos = npos) const noexcept { return find_last_of({&c, 1}, pos); } - constexpr size_t find_last_of(const char* c, size_t pos, size_t count) const { return find_last_of({c, count}, pos); } - size_t find_last_of(const char* c, size_t pos = npos) const { return find_last_of(simple_string_view(c), pos); } - - constexpr size_t find_first_not_of(simple_string_view v, size_t pos = 0) const noexcept { - for (; pos < size_; ++pos) { - bool none = true; - for (char c : v) { - if (data_[pos] == c) { - none = false; - break; - } - } - if (none) return pos; - } - return npos; - } - constexpr size_t find_first_not_of(char c, size_t pos = 0) const noexcept { return find_first_not_of({&c, 1}, pos); } - constexpr size_t find_first_not_of(const char* c, size_t pos, size_t count) const { return find_first_not_of({c, count}, pos); } - size_t find_first_not_of(const char* c, size_t pos = 0) const { return find_first_not_of(simple_string_view(c), pos); } - - constexpr size_t find_last_not_of(simple_string_view v, const size_t pos = npos) const noexcept { - if (size_ == 0) return npos; - const size_t last_pos = std::min(pos, size_-1); - for (size_t i = last_pos; i <= last_pos; --i) { - bool none = true; - for (char c : v) { - if (data_[i] == c) { - none = false; - break; - } - } - if (none) return i; - } - return npos; - } - constexpr size_t find_last_not_of(char c, size_t pos = npos) const noexcept { return find_last_not_of({&c, 1}, pos); } - constexpr size_t find_last_not_of(const char* c, size_t pos, size_t count) const { return find_last_not_of({c, count}, pos); } - size_t find_last_not_of(const char* c, size_t pos = npos) const { return find_last_not_of(simple_string_view(c), pos); } -}; -inline bool operator==(simple_string_view lhs, simple_string_view rhs) { - return lhs.size() == rhs.size() && 0 == std::char_traits::compare(lhs.data(), rhs.data(), lhs.size()); -}; -inline bool operator!=(simple_string_view lhs, simple_string_view rhs) { - return !(lhs == rhs); -} -inline int simple_string_view::compare(simple_string_view s) const { - int cmp = std::char_traits::compare(data_, s.data(), std::min(size_, s.size())); - if (cmp) return cmp; - if (size_ < s.size()) return -1; - else if (size_ > s.size()) return 1; - return 0; -} -inline bool operator<(simple_string_view lhs, simple_string_view rhs) { - return lhs.compare(rhs) < 0; -}; -inline bool operator<=(simple_string_view lhs, simple_string_view rhs) { - return lhs.compare(rhs) <= 0; -}; -inline bool operator>(simple_string_view lhs, simple_string_view rhs) { - return lhs.compare(rhs) > 0; -}; -inline bool operator>=(simple_string_view lhs, simple_string_view rhs) { - return lhs.compare(rhs) >= 0; -}; -inline std::ostream& operator<<(std::ostream& os, const simple_string_view& s) { - os.write(s.data(), s.size()); - return os; -} - -using string_view = simple_string_view; - -} - -#endif - -namespace llarp { - -// Shortcut for explicitly casting a string_view to a string. Saves 8 -// characters compared to `std::string(view)`. -inline std::string str(string_view s) { - return std::string{s}; -} - -} - -#endif diff --git a/llarp/util/thread/logic.hpp b/llarp/util/thread/logic.hpp index 198f6e57e..d94f460d8 100644 --- a/llarp/util/thread/logic.hpp +++ b/llarp/util/thread/logic.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace llarp { @@ -53,7 +53,7 @@ namespace llarp using ID_t = std::thread::id; llarp_threadpool* const m_Thread; llarp_ev_loop* m_Loop = nullptr; - nonstd::optional m_ID; + std::optional m_ID; util::ContentionKiller m_Killer; std::function)> m_Queue; }; diff --git a/llarp/util/thread/queue.hpp b/llarp/util/thread/queue.hpp index ba9f3ed10..002877f48 100644 --- a/llarp/util/thread/queue.hpp +++ b/llarp/util/thread/queue.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -73,10 +73,10 @@ namespace llarp // Remove an element from the queue. Block until an element is available // or until microseconds have elapsed - nonstd::optional + std::optional popFrontWithTimeout(std::chrono::microseconds timeout); - nonstd::optional + std::optional tryPopFront(); // Remove all elements from the queue. Note this is not atomic, and if @@ -263,7 +263,7 @@ namespace llarp } template - nonstd::optional + std::optional Queue::tryPopFront() { uint32_t generation; @@ -288,7 +288,7 @@ namespace llarp // - notify any waiting pushers QueuePopGuard popGuard(*this, generation, index); - return nonstd::optional(std::move(m_data[index])); + return std::optional(std::move(m_data[index])); } template @@ -388,7 +388,7 @@ namespace llarp } template - nonstd::optional + std::optional Queue::popFrontWithTimeout(std::chrono::microseconds timeout) { uint32_t generation = 0; diff --git a/llarp/util/thread/thread_pool.cpp b/llarp/util/thread/thread_pool.cpp index 89e8235cf..99b5c04bb 100644 --- a/llarp/util/thread/thread_pool.cpp +++ b/llarp/util/thread/thread_pool.cpp @@ -153,7 +153,7 @@ namespace llarp } } - ThreadPool::ThreadPool(size_t numThreads, size_t maxJobs, string_view name) + ThreadPool::ThreadPool(size_t numThreads, size_t maxJobs, std::string_view name) : m_queue(maxJobs) , m_semaphore(0) , m_idleThreads(0) diff --git a/llarp/util/thread/thread_pool.hpp b/llarp/util/thread/thread_pool.hpp index 80a870bb6..4002c849e 100644 --- a/llarp/util/thread/thread_pool.hpp +++ b/llarp/util/thread/thread_pool.hpp @@ -1,7 +1,6 @@ #ifndef LLARP_THREAD_POOL_HPP #define LLARP_THREAD_POOL_HPP -#include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include namespace llarp { @@ -84,7 +84,7 @@ namespace llarp } public: - ThreadPool(size_t numThreads, size_t maxJobs, string_view name); + ThreadPool(size_t numThreads, size_t maxJobs, std::string_view name); ~ThreadPool(); diff --git a/llarp/util/thread/threading.hpp b/llarp/util/thread/threading.hpp index f672b79cf..c1d9a5846 100644 --- a/llarp/util/thread/threading.hpp +++ b/llarp/util/thread/threading.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "annotations.hpp" @@ -45,7 +45,7 @@ namespace llarp /// in debug mode, we implement lock() to enforce that any lock is only /// used from a single thread. the point of this is to identify locks that /// are actually needed by dying a painful death when used across threads - mutable nonstd::optional m_id; + mutable std::optional m_id; void lock() const { diff --git a/llarp/util/thread/threadpool.h b/llarp/util/thread/threadpool.h index ff29d5651..0b5354a65 100644 --- a/llarp/util/thread/threadpool.h +++ b/llarp/util/thread/threadpool.h @@ -1,7 +1,6 @@ #ifndef LLARP_THREADPOOL_H #define LLARP_THREADPOOL_H -#include #include #include #include @@ -10,6 +9,7 @@ #include #include +#include struct llarp_threadpool; @@ -18,7 +18,7 @@ struct llarp_threadpool { std::unique_ptr impl; - llarp_threadpool(int workers, llarp::string_view name, size_t queueLength = size_t{1024 * 8}) + llarp_threadpool(int workers, std::string_view name, size_t queueLength = size_t{1024 * 8}) : impl(std::make_unique( workers, std::max(queueLength, size_t{32}), name)) { diff --git a/test/config/test_llarp_config_definition.cpp b/test/config/test_llarp_config_definition.cpp index 7a3bb48dc..827d05344 100644 --- a/test/config/test_llarp_config_definition.cpp +++ b/test/config/test_llarp_config_definition.cpp @@ -1,10 +1,7 @@ #include -#include #include -using llarp::string_view; - TEST_CASE("OptionDefinition int parse test", "[config]") { llarp::OptionDefinition def("foo", "bar", false, 42); @@ -225,7 +222,7 @@ TEST_CASE("ConfigDefinition undeclared definition basic test", "[config]") bool invoked = false; - config.addUndeclaredHandler("foo", [&](string_view section, string_view name, string_view value) { + config.addUndeclaredHandler("foo", [&](std::string_view section, std::string_view name, std::string_view value) { CHECK(section == "foo"); CHECK(name == "bar"); CHECK(value == "val"); @@ -244,11 +241,11 @@ TEST_CASE("ConfigDefinition undeclared add more than once test", "[config]") std::string calledBy = ""; - config.addUndeclaredHandler("foo", [&](string_view, string_view, string_view) { + config.addUndeclaredHandler("foo", [&](std::string_view, std::string_view, std::string_view) { calledBy = "a"; }); REQUIRE_THROWS_WITH( - config.addUndeclaredHandler("foo", [&](string_view, string_view, string_view) { + config.addUndeclaredHandler("foo", [&](std::string_view, std::string_view, std::string_view) { calledBy = "b"; }), "section foo already has a handler"); @@ -265,7 +262,7 @@ TEST_CASE("ConfigDefinition undeclared add/remove test", "[config]") std::string calledBy = ""; // add... - REQUIRE_NOTHROW(config.addUndeclaredHandler("foo", [&](string_view, string_view, string_view) { + REQUIRE_NOTHROW(config.addUndeclaredHandler("foo", [&](std::string_view, std::string_view, std::string_view) { calledBy = "a"; })); @@ -283,7 +280,7 @@ TEST_CASE("ConfigDefinition undeclared add/remove test", "[config]") "no declared section [foo]"); // ...then add again - REQUIRE_NOTHROW(config.addUndeclaredHandler("foo", [&](string_view, string_view, string_view) { + REQUIRE_NOTHROW(config.addUndeclaredHandler("foo", [&](std::string_view, std::string_view, std::string_view) { calledBy = "b"; })); @@ -296,7 +293,7 @@ TEST_CASE("ConfigDefinition undeclared handler exception propagation test", "[co { llarp::ConfigDefinition config; - config.addUndeclaredHandler("foo", [](string_view, string_view, string_view) { + config.addUndeclaredHandler("foo", [](std::string_view, std::string_view, std::string_view) { throw std::runtime_error("FAIL"); }); @@ -307,7 +304,7 @@ TEST_CASE("ConfigDefinition undeclared handler wrong section", "[config]") { llarp::ConfigDefinition config; - config.addUndeclaredHandler("foo", [](string_view, string_view, string_view) { + config.addUndeclaredHandler("foo", [](std::string_view, std::string_view, std::string_view) { throw std::runtime_error("FAIL"); }); @@ -320,7 +317,7 @@ TEST_CASE("ConfigDefinition undeclared handler duplicate names", "[config]") int count = 0; - config.addUndeclaredHandler("foo", [&](string_view, string_view, string_view) { + config.addUndeclaredHandler("foo", [&](std::string_view, std::string_view, std::string_view) { count++; }); @@ -375,7 +372,7 @@ TEST_CASE("ConfigDefinition [bind]iface regression", "[config regression]") config.defineOption( "bind", "*", false, false, "1090", [&](std::string arg) { val1 = arg; }); - config.addUndeclaredHandler("bind", [&](string_view, string_view name, string_view value) { + config.addUndeclaredHandler("bind", [&](std::string_view, std::string_view name, std::string_view value) { undeclaredName = std::string(name); undeclaredValue = std::string(value); }); diff --git a/test/dht/mock_context.hpp b/test/dht/mock_context.hpp index fdfb46272..dac797fb0 100644 --- a/test/dht/mock_context.hpp +++ b/test/dht/mock_context.hpp @@ -72,7 +72,7 @@ namespace llarp void(const dht::Key_t&, AbstractRouter*)); MOCK_CONST_METHOD1(GetIntroSetByLocation, - nonstd::optional< llarp::service::EncryptedIntroSet >( + std::optional< llarp::service::EncryptedIntroSet >( const llarp::dht::Key_t&)); MOCK_CONST_METHOD0(ExtractStatus, util::StatusObject()); diff --git a/test/util/test_llarp_util_log_level.cpp b/test/util/test_llarp_util_log_level.cpp index 47332d6d4..527212ba4 100644 --- a/test/util/test_llarp_util_log_level.cpp +++ b/test/util/test_llarp_util_log_level.cpp @@ -8,7 +8,7 @@ using TestString = std::string; struct TestParseLog { TestString input; - nonstd::optional< llarp::LogLevel > level; + std::optional< llarp::LogLevel > level; }; struct LogLevelTest : public ::testing::TestWithParam< TestParseLog > diff --git a/test/util/thread/test_llarp_util_queue.cpp b/test/util/thread/test_llarp_util_queue.cpp index afa030795..f891c6b7e 100644 --- a/test/util/thread/test_llarp_util_queue.cpp +++ b/test/util/thread/test_llarp_util_queue.cpp @@ -575,7 +575,7 @@ TEST(TestQueue, moveIt) ASSERT_EQ(5u, counter); - nonstd::optional< MoveTester > optPopped = queue.tryPopFront(); + std::optional< MoveTester > optPopped = queue.tryPopFront(); ASSERT_TRUE(optPopped.has_value()); diff --git a/test/util/thread/test_llarp_util_queue_manager.cpp b/test/util/thread/test_llarp_util_queue_manager.cpp index 3620de453..aaeca1421 100644 --- a/test/util/thread/test_llarp_util_queue_manager.cpp +++ b/test/util/thread/test_llarp_util_queue_manager.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -75,7 +75,7 @@ class IntQueue } } - nonstd::optional< int > + std::optional< int > tryPopFront() { uint32_t gen = 0;