Commit 57f6de32 authored by Jens Wehner's avatar Jens Wehner

used unique_ptr

parent 5dcdd30b
Pipeline #94355078 failed with stages
in 4 minutes and 59 seconds
......@@ -50,7 +50,7 @@ void check_option(po::options_description &desc, po::variables_map &vm,
int main(int argc, char **argv) {
string in_file, out_file, grid, fitgrid, comment, type, boundaries;
Spline *spline = nullptr;
Table in, out, der;
// program options
po::options_description desc("Allowed options");
......@@ -120,16 +120,16 @@ int main(int argc, char **argv) {
}
in.Load(in_file);
std::unique_ptr<Spline> spline;
if (vm.count("type")) {
if (type == "cubic") {
spline = new CubicSpline();
spline = std::make_unique<CubicSpline>(CubicSpline());
} else if (type == "akima") {
spline = new AkimaSpline();
spline = std::make_unique<AkimaSpline>(AkimaSpline());
} else if (type == "linear") {
spline = new LinSpline();
spline = std::make_unique<LinSpline>(LinSpline());
} else {
throw std::runtime_error("unknown type");
throw std::runtime_error("unknown spline type:" + type);
}
}
spline->setBC(Spline::splineNormal);
......@@ -250,7 +250,7 @@ int main(int argc, char **argv) {
for (; i < out.size(); ++i) {
for (; j < in.size(); ++j) {
if (in.x(j) >= out.x(i) ||
fabs(in.x(j) - out.x(i)) < 1e-12) { // fix for precison errors
std::abs(in.x(j) - out.x(i)) < 1e-12) { // fix for precision errors
break;
}
}
......@@ -269,10 +269,7 @@ int main(int argc, char **argv) {
der.Save(vm["derivative"].as<string>());
}
delete spline;
}
catch (std::exception &error) {
} catch (std::exception &error) {
cerr << "an error occurred:\n" << error.what() << endl;
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment