Add support for `std::vector::size()`
Closed this issue · 0 comments
gojakuch commented
#include "clad/Differentiator/Differentiator.h"
#include "clad/Differentiator/STLBuiltins.h"
#include <iostream>
double fn(double x, double y) {
std::vector<double> v;
for (size_t i = 0; i < v.size(); ++i) {
v.push_back(x);
}
return v[0];
}
int main(int argc, char* argv[]) {
double dx, dy;
auto df = clad::gradient(fn, "x, y");
std::cout << fn(3, 4) << '\n';
dx = 0; dy = 0;
df.execute(3, 4, &dx, &dy);
std::cout << dx << ' ' << dy << '\n';
}
this code currently crashes because of the v.size()
usage.