3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-09 02:25:38 +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:
Copilot 2026-01-21 19:54:53 -08:00 committed by GitHub
parent 4681c51413
commit b0313ca80a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 89 additions and 29 deletions

View file

@ -22,6 +22,7 @@ Revision History:
#pragma once
#include <cstddef>
#include <span>
#include "util/memory_manager.h"
template<typename T, bool CallDestructors=true, unsigned INITIAL_SIZE=16>
@ -192,12 +193,17 @@ public:
return m_buffer;
}
void append(unsigned n, T const * elems) {
for (unsigned i = 0; i < n; ++i) {
push_back(elems[i]);
void append(std::span<T const> elems) {
for (auto const& elem : elems) {
push_back(elem);
}
}
// Backward compatibility overload
void append(unsigned n, T const * elems) {
append(std::span<T const>(elems, n));
}
void append(const buffer& source) {
append(source.size(), source.data());
}
@ -265,11 +271,16 @@ public:
template<typename T, unsigned INITIAL_SIZE=16>
class ptr_buffer : public buffer<T *, false, INITIAL_SIZE> {
public:
void append(unsigned n, T * const * elems) {
for (unsigned i = 0; i < n; ++i) {
this->push_back(elems[i]);
void append(std::span<T * const> elems) {
for (auto elem : elems) {
this->push_back(elem);
}
}
// Backward compatibility overload
void append(unsigned n, T * const * elems) {
append(std::span<T * const>(elems, n));
}
};
template<typename T, unsigned INITIAL_SIZE=16>