mirror of
https://github.com/Z3Prover/z3
synced 2026-01-28 21:08:43 +00:00
Extend std::span adoption to utility and AST functions (#8271)
* Initial plan * Add std::span to utility functions (buffer, ref_buffer, permutation, util) Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Add std::span to ast_manager array ref functions Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Fix: Use consistent int loop variable in apply_permutation Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
4681c51413
commit
b0313ca80a
5 changed files with 89 additions and 29 deletions
|
|
@ -48,6 +48,7 @@ Revision History:
|
|||
#include "util/dependency.h"
|
||||
#include "util/rlimit.h"
|
||||
#include <variant>
|
||||
#include <span>
|
||||
|
||||
#define RECYCLE_FREE_AST_INDICES
|
||||
|
||||
|
|
@ -1667,17 +1668,29 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void inc_array_ref(unsigned sz, T * const * a) {
|
||||
for(unsigned i = 0; i < sz; ++i) {
|
||||
inc_ref(a[i]);
|
||||
void inc_array_ref(std::span<T * const> a) {
|
||||
for(auto elem : a) {
|
||||
inc_ref(elem);
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility overload
|
||||
template<typename T>
|
||||
void inc_array_ref(unsigned sz, T * const * a) {
|
||||
inc_array_ref(std::span<T * const>(a, sz));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void dec_array_ref(std::span<T * const> a) {
|
||||
for(auto elem : a) {
|
||||
dec_ref(elem);
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility overload
|
||||
template<typename T>
|
||||
void dec_array_ref(unsigned sz, T * const * a) {
|
||||
for(unsigned i = 0; i < sz; ++i) {
|
||||
dec_ref(a[i]);
|
||||
}
|
||||
dec_array_ref(std::span<T * const>(a, sz));
|
||||
}
|
||||
|
||||
static unsigned get_node_size(ast const * n);
|
||||
|
|
@ -2405,11 +2418,17 @@ private:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void push_dec_array_ref(unsigned sz, T * const * a) {
|
||||
for(unsigned i = 0; i < sz; ++i) {
|
||||
push_dec_ref(a[i]);
|
||||
void push_dec_array_ref(std::span<T * const> a) {
|
||||
for(auto elem : a) {
|
||||
push_dec_ref(elem);
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility overload
|
||||
template<typename T>
|
||||
void push_dec_array_ref(unsigned sz, T * const * a) {
|
||||
push_dec_array_ref(std::span<T * const>(a, sz));
|
||||
}
|
||||
};
|
||||
|
||||
typedef ast_manager::expr_array expr_array;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue