diff --git a/src/generator/config/subexport.cpp b/src/generator/config/subexport.cpp index 66260c95a..8dcb27bc8 100644 --- a/src/generator/config/subexport.cpp +++ b/src/generator/config/subexport.cpp @@ -116,7 +116,7 @@ bool applyMatcher(const std::string &rule, std::string &real_rule, const Proxy & std::string target, ret_real_rule; static const std::string groupid_regex = R"(^!!(?:GROUPID|INSERT)=([\d\-+!,]+)(?:!!(.*))?$)", group_regex = R"(^!!(?:GROUP)=(.+?)(?:!!(.*))?$)"; static const std::string type_regex = R"(^!!(?:TYPE)=(.+?)(?:!!(.*))?$)", port_regex = R"(^!!(?:PORT)=(.+?)(?:!!(.*))?$)", server_regex = R"(^!!(?:SERVER)=(.+?)(?:!!(.*))?$)"; - static const string_array types = {"", "SS", "SSR", "VMESS", "TROJAN", "SNELL", "HTTP", "HTTPS", "SOCKS5"}; + static const string_array types = {"", "SS", "SSR", "VMESS", "TROJAN", "SNELL", "HTTP", "HTTPS", "SOCKS5", "WIREGUARD"}; if(startsWith(rule, "!!GROUP=")) { regGetMatch(rule, group_regex, 3, 0, &target, &ret_real_rule); @@ -155,7 +155,7 @@ bool applyMatcher(const std::string &rule, std::string &real_rule, const Proxy & return true; } -void processRemark(std::string &remark, string_array &remarks_list, bool proc_comma = true) +void processRemark(std::string &remark, const string_array &remarks_list, bool proc_comma = true) { // Replace every '=' with '-' in the remark string to avoid parse errors from the clients. // Surge is tested to yield an error when handling '=' in the remark string, @@ -172,7 +172,7 @@ void processRemark(std::string &remark, string_array &remarks_list, bool proc_co } std::string tempRemark = remark; int cnt = 2; - while(std::find(remarks_list.begin(), remarks_list.end(), tempRemark) != remarks_list.end()) + while(std::find(remarks_list.cbegin(), remarks_list.cend(), tempRemark) != remarks_list.cbegin()) { tempRemark = remark + " " + std::to_string(cnt); cnt++; diff --git a/src/utils/rapidjson_extra.h b/src/utils/rapidjson_extra.h index c5fd5c2fe..67ee63719 100644 --- a/src/utils/rapidjson_extra.h +++ b/src/utils/rapidjson_extra.h @@ -93,6 +93,16 @@ namespace rapidjson_ext { { return (*this)(root); }; + + friend ReturnType operator| (rapidjson::Value &root, const ExtensionFunction &func) + { + return func(root); + } + + friend ReturnType operator| (rapidjson::Value &&root, const ExtensionFunction &func) + { + return func(root); + } }; struct AddMemberOrReplace : public ExtensionFunction { @@ -165,18 +175,6 @@ namespace rapidjson_ext { return buffer.GetString(); } }; - - template - inline ReturnType operator| (rapidjson::Value &root, const ExtensionFunction &func) - { - return func(root); - } - - template - inline ReturnType operator| (rapidjson::Value &&root, const ExtensionFunction &func) - { - return func(root); - } } diff --git a/src/utils/stl_extra.h b/src/utils/stl_extra.h index 6e14390cd..49c84c0ae 100644 --- a/src/utils/stl_extra.h +++ b/src/utils/stl_extra.h @@ -14,25 +14,37 @@ template inline void eraseElements(T &target) T().swap(target); } -template -concept ConstIterable = requires(Container a, Element b) { +#if __cpp_concepts >= 201907L // C++20 concepts supported (g++-10 or clang++-10) + +template +concept ConstIterable = requires(Container a) { { a.cbegin() } -> std::same_as; { a.cend() } -> std::same_as; typename Container::const_reference; }; -template -concept Iterable = requires(Container a, Element b) { +template +concept Iterable = requires(Container a) { { a.begin() } -> std::same_as; { a.end() } -> std::same_as; typename Container::reference; }; template -requires ConstIterable -inline bool none_of(ConstIterableContainer &container, std::function func) +requires ConstIterable +inline bool none_of(const ConstIterableContainer &container, std::function func) { return std::none_of(container.cbegin(), container.cend(), func); } +#else // __cpp_concepts >= 201907L + +template +inline bool none_of(const Container &container, std::function func) +{ + return std::none_of(container.cbegin(), container.cend(), func); +} + +#endif // __cpp_concepts >= 201907L + #endif // STL_EXTRA_H_INCLUDED