---
title: "ClikaRT::graph::RewriteMatch"
sidebar_label: "RewriteMatch"
description: "One occurrence a rule rewrites, read on the graph as the rule's earlier replacements in the same iteration left it."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--struct">struct</span>

**Header:** `ClikaRT/graph/rewrite.h`

`transforms::rewrite`: a transform written as a rule. The rule finds every occurrence of a `Pattern`, keeps the ones its condition accepts, and replaces each with the values its replacement computes from the occurrence's inputs, through `ModelGraph::replace`, so every rule an edit keeps (the type rule, the count, validate-first) holds for the rule too. `optimize` runs it as it runs a transform you write with `Transform::from_function`: one report row, the order `runs_after` keeps, and the failure that ends the run and leaves the graph as `optimize` found it.

One occurrence a rule rewrites, read on the graph as the rule's earlier replacements in the same iteration left it.

## Data members

### nodes {#nodes}

<div class="api-signature">

`std::vector<std::optional<`[`Node`](./Node.md)`>>` **`nodes`**

</div>

The matched node per pattern node, in `add_node` order, as [`Match::nodes`](./Match.md#nodes) holds them: `std::nullopt` for an optional node the occurrence lacks.

<div class="api-declared">

Declared in `ClikaRT/graph/rewrite.h`, line 36

</div>

### inputs {#inputs}

<div class="api-signature">

`std::vector<`[`Value`](./Value.md)`>` **`inputs`**

</div>

The values the occurrence reads from outside it: every input of a matched node that no matched node makes, in pattern-node order and then input-port order, each listed once. A constant is one of them.

<div class="api-declared">

Declared in `ClikaRT/graph/rewrite.h`, line 40

</div>

### outputs {#outputs}

<div class="api-signature">

`std::vector<`[`Value`](./Value.md)`>` **`outputs`**

</div>

The values the occurrence makes that a node outside it reads or the graph returns, in the same order, each listed once. A value a matched node reads is an output too when a node outside reads it as well.

<div class="api-declared">

Declared in `ClikaRT/graph/rewrite.h`, line 44

</div>
