mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-05 03:02:06 +00:00
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:
3 files changed
+31
-21
No files matched your search
+10
-12
@@ -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
@@ -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
|
||||
Reference in new issue
Block a user