From 772d927e1919d22f3b57c2663850ea552f752e56 Mon Sep 17 00:00:00 2001 From: Alexander Ivanov Date: Thu, 12 Jan 2023 09:09:35 +0000 Subject: [PATCH] Replacing old style typedefs with new style usings Change-Id: I85d353708fc431df8312a2337d0508df6aee071f --- internal/ceres/accelerate_sparse.h | 16 +++++------ .../ceres/cost_function_to_functor_test.cc | 27 +++++++++---------- internal/ceres/linear_solver.h | 8 +++--- internal/ceres/suitesparse.h | 2 +- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/internal/ceres/accelerate_sparse.h b/internal/ceres/accelerate_sparse.h index 81f5b9420..fdc53e55b 100644 --- a/internal/ceres/accelerate_sparse.h +++ b/internal/ceres/accelerate_sparse.h @@ -55,18 +55,18 @@ struct SparseTypesTrait {}; template <> struct SparseTypesTrait { - typedef DenseVector_Double DenseVector; - typedef SparseMatrix_Double SparseMatrix; - typedef SparseOpaqueSymbolicFactorization SymbolicFactorization; - typedef SparseOpaqueFactorization_Double NumericFactorization; + using DenseVector = DenseVector_Double; + using SparseMatrix = SparseMatrix_Double; + using SymbolicFactorization = SparseOpaqueSymbolicFactorization; + using NumericFactorization = SparseOpaqueFactorization_Double; }; template <> struct SparseTypesTrait { - typedef DenseVector_Float DenseVector; - typedef SparseMatrix_Float SparseMatrix; - typedef SparseOpaqueSymbolicFactorization SymbolicFactorization; - typedef SparseOpaqueFactorization_Float NumericFactorization; + using DenseVector = DenseVector_Float; + using SparseMatrix = SparseMatrix_Float; + using SymbolicFactorization = SparseOpaqueSymbolicFactorization; + using NumericFactorization = SparseOpaqueFactorization_Float; }; template diff --git a/internal/ceres/cost_function_to_functor_test.cc b/internal/ceres/cost_function_to_functor_test.cc index cf4a57b79..374990975 100644 --- a/internal/ceres/cost_function_to_functor_test.cc +++ b/internal/ceres/cost_function_to_functor_test.cc @@ -298,20 +298,19 @@ class DynamicTwoParameterBlockFunctor { }; // Check that AutoDiff(Functor1) == AutoDiff(CostToFunctor(AutoDiff(Functor1))) -#define TEST_BODY(Functor1) \ - TEST(CostFunctionToFunctor, Functor1) { \ - typedef AutoDiffCostFunction \ - CostFunction1; \ - typedef CostFunctionToFunctor<2, PARAMETER_BLOCK_SIZES> FunctionToFunctor; \ - typedef AutoDiffCostFunction \ - CostFunction2; \ - \ - std::unique_ptr cost_function(new CostFunction2( \ - new FunctionToFunctor(new CostFunction1(new Functor1)))); \ - \ - std::unique_ptr actual_cost_function( \ - new CostFunction1(new Functor1)); \ - ExpectCostFunctionsAreEqual(*cost_function, *actual_cost_function); \ +#define TEST_BODY(Functor1) \ + TEST(CostFunctionToFunctor, Functor1) { \ + using CostFunction1 = AutoDiffCostFunction; \ + using FunctionToFunctor = CostFunctionToFunctor<2, PARAMETER_BLOCK_SIZES>; \ + using CostFunction2 = \ + AutoDiffCostFunction; \ + \ + std::unique_ptr cost_function(new CostFunction2( \ + new FunctionToFunctor(new CostFunction1(new Functor1)))); \ + \ + std::unique_ptr actual_cost_function( \ + new CostFunction1(new Functor1)); \ + ExpectCostFunctionsAreEqual(*cost_function, *actual_cost_function); \ } #define PARAMETER_BLOCK_SIZES 2 diff --git a/internal/ceres/linear_solver.h b/internal/ceres/linear_solver.h index 757d01e0f..413160fc3 100644 --- a/internal/ceres/linear_solver.h +++ b/internal/ceres/linear_solver.h @@ -392,10 +392,10 @@ class TypedLinearSolver : public LinearSolver { // Linear solvers that depend on access to the low level structure of // a SparseMatrix. // clang-format off -typedef TypedLinearSolver BlockSparseMatrixSolver; // NOLINT -typedef TypedLinearSolver CompressedRowSparseMatrixSolver; // NOLINT -typedef TypedLinearSolver DenseSparseMatrixSolver; // NOLINT -typedef TypedLinearSolver TripletSparseMatrixSolver; // NOLINT +using BlockSparseMatrixSolver = TypedLinearSolver; // NOLINT +using CompressedRowSparseMatrixSolver = TypedLinearSolver; // NOLINT +using DenseSparseMatrixSolver = TypedLinearSolver; // NOLINT +using TripletSparseMatrixSolver = TypedLinearSolver; // NOLINT // clang-format on } // namespace ceres::internal diff --git a/internal/ceres/suitesparse.h b/internal/ceres/suitesparse.h index aeea7b2e2..e00b82d01 100644 --- a/internal/ceres/suitesparse.h +++ b/internal/ceres/suitesparse.h @@ -274,7 +274,7 @@ class CERES_NO_EXPORT SuiteSparseCholesky final : public SparseCholesky { #else // CERES_NO_SUITESPARSE -typedef void cholmod_factor; +using cholmod_factor = void; #include "ceres/internal/disable_warnings.h"