diff --git a/include/ceres/problem.h b/include/ceres/problem.h index 278d80fe4..a4a6c8ffa 100644 --- a/include/ceres/problem.h +++ b/include/ceres/problem.h @@ -189,8 +189,11 @@ class CERES_EXPORT Problem { // invocation Problem(Problem::Options()). Problem(); explicit Problem(const Options& options); + Problem(Problem&&) = default; + Problem& operator=(Problem&&) = default; + Problem(const Problem&) = delete; - void operator=(const Problem&) = delete; + Problem& operator=(const Problem&) = delete; ~Problem(); diff --git a/internal/ceres/problem_test.cc b/internal/ceres/problem_test.cc index 038600c37..b77952410 100644 --- a/internal/ceres/problem_test.cc +++ b/internal/ceres/problem_test.cc @@ -122,6 +122,24 @@ class TernaryCostFunction: public CostFunction { } }; + +TEST(Problem, MoveConstructor) { + Problem src; + double x; + src.AddParameterBlock(&x, 1); + Problem dst(std::move(src)); + EXPECT_TRUE(dst.HasParameterBlock(&x)); +} + +TEST(Problem, MoveAssignment) { + Problem src; + double x; + src.AddParameterBlock(&x, 1); + Problem dst; + dst = std::move(src); + EXPECT_TRUE(dst.HasParameterBlock(&x)); +} + TEST(Problem, AddResidualWithNullCostFunctionDies) { double x[3], y[4], z[5];