mirror of
https://github.com/Z3Prover/z3
synced 2026-01-16 07:36:15 +00:00
* Initial plan * Add [[nodiscard]] to AST factory functions and modernize iterator loops - Added [[nodiscard]] attribute to key factory functions in ast.h: - All mk_app() variants for creating application nodes - All mk_func_decl() variants for creating function declarations - All mk_const() variants for creating constants - All mk_sort() variants for creating sorts - mk_var() for creating variables - mk_quantifier(), mk_forall(), mk_exists(), mk_lambda() for quantifiers - mk_label(), mk_pattern() and related functions - Converted iterator loops to range-based for loops in: - src/util/region.cpp: pop_scope() - src/util/dec_ref_util.h: dec_ref_key_values(), dec_ref_keys(), dec_ref_values() - src/util/mpf.h: dispose() - src/util/numeral_buffer.h: reset() Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Modernize additional iterator loops to range-based for loops - Converted iterator loops to range-based for loops in: - src/api/api_ast_map.cpp: Z3_ast_map_keys() and Z3_ast_map_to_string() - src/api/c++/z3++.h: optimize copy constructor and add() method - src/opt/wmax.cpp: mk_assumptions() Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Revert changes to z3++.h for C++ version compatibility Revert the range-based for loop changes in src/api/c++/z3++.h to maintain compatibility with older C++ versions that users may rely on. The C++ API wrapper must support down-level C++ standards for backward compatibility. Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Trigger CI build [skip ci] is not used to ensure CI runs --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
87 lines
1.6 KiB
C++
87 lines
1.6 KiB
C++
/*++
|
|
Copyright (c) 2011 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
numeral_buffer.h
|
|
|
|
Abstract:
|
|
|
|
Basic buffer for managing big nums.
|
|
|
|
Author:
|
|
|
|
Leonardo de Moura (leonardo) 2011-06-18.
|
|
|
|
Revision History:
|
|
|
|
--*/
|
|
#pragma once
|
|
|
|
#include "util/vector.h"
|
|
|
|
template<typename Numeral, typename NumeralManager>
|
|
class numeral_buffer {
|
|
NumeralManager & m_manager;
|
|
svector<Numeral> m_buffer;
|
|
public:
|
|
typedef Numeral numeral;
|
|
typedef Numeral data_t;
|
|
typedef NumeralManager manager;
|
|
|
|
numeral_buffer(NumeralManager & m):m_manager(m) {}
|
|
|
|
~numeral_buffer() {
|
|
reset();
|
|
}
|
|
|
|
NumeralManager & m() const { return m_manager; }
|
|
|
|
unsigned size() const { return m_buffer.size(); }
|
|
|
|
bool empty() const { return m_buffer.empty(); }
|
|
|
|
void push_back(Numeral const & num) {
|
|
m_buffer.push_back(Numeral());
|
|
m().set(m_buffer.back(), num);
|
|
}
|
|
|
|
void pop_back() {
|
|
m().del(m_buffer.back());
|
|
m_buffer.pop_back();
|
|
}
|
|
|
|
Numeral & back() {
|
|
return m_buffer.back();
|
|
}
|
|
|
|
Numeral const & back() const {
|
|
return m_buffer.back();
|
|
}
|
|
|
|
Numeral const & operator[](unsigned idx) const {
|
|
return m_buffer[idx];
|
|
}
|
|
|
|
Numeral & operator[](unsigned idx) {
|
|
return m_buffer[idx];
|
|
}
|
|
|
|
void reset() {
|
|
for (auto& numeral : m_buffer)
|
|
m().del(numeral);
|
|
m_buffer.reset();
|
|
}
|
|
|
|
Numeral * data() { return m_buffer.data(); }
|
|
|
|
void reserve(unsigned sz) {
|
|
m_buffer.reserve(sz);
|
|
}
|
|
|
|
void swap(svector<Numeral> & other) noexcept {
|
|
m_buffer.swap(other);
|
|
}
|
|
|
|
};
|
|
|