Enhancements

Fix crash when using WireGuard as type filter rule.
Fix support for compiler older than gcc-10 or clang-10.
Optimize codes.
This commit is contained in:
Tindy X committed 2023-11-13 21:07:59 +08:00
1 parent 7ea43f9c01
commit b71cd1e668
3 files changed
+31 -21

No files matched your search

+10 -12
View File
@@ -93,6 +93,16 @@ namespace rapidjson_ext {
{
return (*this)(root);
};
friend ReturnType operator| (rapidjson::Value &root, const ExtensionFunction<ReturnType> &func)
{
return func(root);
}
friend ReturnType operator| (rapidjson::Value &&root, const ExtensionFunction<ReturnType> &func)
{
return func(root);
}
};
struct AddMemberOrReplace : public ExtensionFunction<rapidjson::Value &> {
@@ -165,18 +175,6 @@ namespace rapidjson_ext {
return buffer.GetString();
}
};
template <typename ReturnType>
inline ReturnType operator| (rapidjson::Value &root, const ExtensionFunction<ReturnType> &func)
{
return func(root);
}
template <typename ReturnType>
inline ReturnType operator| (rapidjson::Value &&root, const ExtensionFunction<ReturnType> &func)
{
return func(root);
}
}
+18 -6
View File
@@ -14,25 +14,37 @@ template <typename T> inline void eraseElements(T &target)
T().swap(target);
}
template <typename Container, typename Element>
concept ConstIterable = requires(Container a, Element b) {
#if __cpp_concepts >= 201907L // C++20 concepts supported (g++-10 or clang++-10)
template <typename Container>
concept ConstIterable = requires(Container a) {
{ a.cbegin() } -> std::same_as<typename Container::const_iterator>;
{ a.cend() } -> std::same_as<typename Container::const_iterator>;
typename Container::const_reference;
};
template <typename Container, typename Element>
concept Iterable = requires(Container a, Element b) {
template <typename Container>
concept Iterable = requires(Container a) {
{ a.begin() } -> std::same_as<typename Container::iterator>;
{ a.end() } -> std::same_as<typename Container::iterator>;
typename Container::reference;
};
template <typename ConstIterableContainer>
requires ConstIterable<ConstIterableContainer, typename ConstIterableContainer::value_type>
inline bool none_of(ConstIterableContainer &container, std::function<bool(typename ConstIterableContainer::const_reference)> func)
requires ConstIterable<ConstIterableContainer>
inline bool none_of(const ConstIterableContainer &container, std::function<bool(typename ConstIterableContainer::const_reference)> func)
{
return std::none_of(container.cbegin(), container.cend(), func);
}
#else // __cpp_concepts >= 201907L
template <typename Container>
inline bool none_of(const Container &container, std::function<bool(typename Container::const_reference)> func)
{
return std::none_of(container.cbegin(), container.cend(), func);
}
#endif // __cpp_concepts >= 201907L
#endif // STL_EXTRA_H_INCLUDED