Skip to content

Commit

Permalink
Linear exporting to C++ now also creates ExportedCode
Browse files Browse the repository at this point in the history
  • Loading branch information
benruijl committed Jul 19, 2024
1 parent 13d6bff commit 3808339
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ impl<T> ExpressionEvaluator<T> {
}

impl<T: std::fmt::Display> ExpressionEvaluator<T> {
pub fn export_cpp(&self) -> String {
/// Create a C++ code representation of the evaluation tree.
pub fn export_cpp(&self, filename: &str) -> Result<ExportedCode, std::io::Error> {
let cpp = self.export_cpp_str();
std::fs::write(filename, cpp)?;
Ok(ExportedCode(filename.to_string()))
}

pub fn export_cpp_str(&self) -> String {
let mut res = String::new();
res += &format!("\ntemplate<typename T>\nvoid eval(T* params, T* out) {{\n");

Expand Down

0 comments on commit 3808339

Please sign in to comment.