3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

remove unsound rewrite

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-11-19 00:48:33 -08:00
parent 6ef2557e2a
commit 529e62e01e
3 changed files with 43 additions and 1 deletions

View file

@ -186,6 +186,7 @@ public:
std::swap(m_nodes[i], m_nodes[sz-i-1]);
}
}
};
template<typename T, typename TManager>
@ -304,6 +305,31 @@ public:
// prevent abuse:
ref_vector & operator=(ref_vector const & other) = delete;
ref_vector&& filter(std::function<bool(T)>& predicate) {
ref_vector result(m());
for (auto& t : *this)
if (predicate(t)) result.push_back(t);
return result;
}
template <typename S>
vector<S>&& map(std::function<S(T)>& f) {
vector<S> result;
for (auto& t : *this)
result.push_back(f(t));
return result;
}
ref_vector&& map(std::function<T(T)>& f) {
ref_vector result(m());
for (auto& t : *this)
result.push_back(f(t));
return result;
}
};
template<typename T>

View file

@ -28,6 +28,7 @@ Revision History:
#include<algorithm>
#include<type_traits>
#include<memory.h>
#include<functional>
#include "util/memory_manager.h"
#include "util/hash.h"
#include "util/z3_exception.h"
@ -230,6 +231,21 @@ public:
return *this;
}
vector&& filter(std::function<bool(T)>& predicate) {
vector result;
for (auto& t : *this)
if (predicate(t)) result.push_back(t);
return result;
}
template <typename S>
vector<S>&& map(std::function<S(T)>& f) {
vector<S> result;
for (auto& t : *this)
result.push_back(f(t));
return result;
}
void reset() {
if (m_data) {
if (CallDestructors) {