mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-30 17:10:38 +08:00
Modernize CostFunction and FirstOrderFunction constructors
- Add constructors taking std::unique_ptr and ceres::Ownership to AutoDiffCostFunction, NumericDiffCostFunction, and their dynamic and first-order counterparts. - Standardize delegating constructor style to use parentheses. - Standardize ownership check in destructors. - Fix documentation typos and example code in headers. - Add comprehensive tests for Ownership and unique_ptr constructors. Change-Id: I573abd695cdd89905997b573620e8d99d1cacca2
This commit is contained in:
@@ -525,9 +525,19 @@ TEST(DynamicNumericdiffCostFunctionTest, ArgumentForwarding) {
|
||||
(void)DynamicNumericDiffCostFunction<MyCostFunctor>();
|
||||
}
|
||||
|
||||
TEST(DynamicAutoDiffCostFunctionTest, UniquePtr) {
|
||||
TEST(DynamicNumericDiffCostFunctionTest, UniquePtr) {
|
||||
(void)DynamicNumericDiffCostFunction<MyCostFunctor>(
|
||||
std::make_unique<MyCostFunctor>());
|
||||
}
|
||||
|
||||
TEST(DynamicNumericDiffCostFunctionTest, Ownership) {
|
||||
MyCostFunctor functor;
|
||||
{
|
||||
DynamicNumericDiffCostFunction<MyCostFunctor> cost_function(
|
||||
&functor, DO_NOT_TAKE_OWNERSHIP);
|
||||
cost_function.AddParameterBlock(3);
|
||||
cost_function.SetNumResiduals(3);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ceres::internal
|
||||
|
||||
Reference in New Issue
Block a user