8#include "../bool/bool.hpp"
9#include "../safe_uint/safe_uint.hpp"
23 for (
const auto& e : arr) {
25 hit_zero.
must_imply(is_zero,
"Once we've hit the first zero, there must only be zeros thereafter!");
44 for (
size_t i = arr.size() - 1; i != (size_t)-1; i--) {
48 already_popped |= is_non_zero;
50 already_popped.
assert_equal(
true,
"array_pop cannot pop from an empty array");
59template <
typename Builder,
size_t SIZE>
63 for (
size_t i = 0; i < arr.size(); ++i) {
67 already_pushed |= is_zero;
69 already_pushed.
assert_equal(
true,
"array_push cannot push to a full array");
76template <
typename Builder,
size_t SIZE>
79 for (
size_t i = 0; i < arr.size(); ++i) {
92template <
typename T,
size_t SIZE>
95 for (
size_t i = 0; i < arr.size(); ++i) {
96 if (arr[i] ==
nullptr) {
111 for (
size_t i = 0; i < arr.size(); ++i) {
113 arr[i].conditional_select(!already_pushed && is_zero,
value);
115 already_pushed |= is_zero;
117 already_pushed.
assert_equal(
true,
"array_push cannot push to a full array");
124template <
typename Builder,
size_t SIZE>
128 for (
size_t i = arr.size() - 1; i != (size_t)-1; i--) {
130 nonzero_found |= is_non_zero;
132 return !nonzero_found;
139template <
typename Builder,
size_t size_1,
size_t size_2>
153 for (
size_t i = 0; i < source.max_size(); ++i) {
157 auto is_s_zero = s.is_zero();
159 "Once we've hit the first source zero, there must only be zeros thereafter!");
160 hit_s_zero |= is_s_zero;
161 not_hit_s_zero = !hit_s_zero;
165 for (
size_t j = i; j < target.max_size(); ++j) {
176 next_target_index += not_hit_s_zero;
178 next_target_index.
assert_not_equal(overflow_capacity,
"push_array_to_array target array capacity exceeded");
Implements boolean logic in-circuit.
void must_imply(const bool_t &other, std::string const &msg="bool_t::must_imply") const
Constrains the (a => b) == true.
void assert_equal(const bool_t &rhs, std::string const &msg="bool_t::assert_equal") const
Implements copy constraint for bool_t elements.
void assert_not_equal(const field_t &rhs, std::string const &msg="field_t::assert_not_equal") const
Constrain *this to be not equal to rhs.
static field_t conditional_assign(const bool_t< Builder > &predicate, const field_t &lhs, const field_t &rhs)
If predicate == true then return lhs, else return rhs.
uint8_t const size_t length
void array_push(std::array< field_t< Builder >, SIZE > &arr, field_t< Builder > const &value)
stdlib::bool_t< Builder > is_array_empty(std::array< field_t< Builder >, SIZE > const &arr)
field_t< Builder > array_length(std::array< field_t< Builder >, SIZE > const &arr)
field_t< Builder > array_pop(std::array< field_t< Builder >, SIZE > const &arr)
void push_array_to_array(std::array< field_t< Builder >, size_1 > const &source, std::array< field_t< Builder >, size_2 > &target)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
void throw_or_abort(std::string const &err)