From 0a501a561549d98181b1fc6d1d8dfb34042b2ba2 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 3 May 2021 17:01:18 -0400 Subject: [PATCH 1/2] fix warnings from tests --- gtsam/geometry/CalibratedCamera.h | 18 ++++----- gtsam/inference/Factor.h | 61 +++++++++++++++++-------------- gtsam/inference/FactorGraph.h | 4 ++ 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/gtsam/geometry/CalibratedCamera.h b/gtsam/geometry/CalibratedCamera.h index 97ebe8c7eb..1d4a379a19 100644 --- a/gtsam/geometry/CalibratedCamera.h +++ b/gtsam/geometry/CalibratedCamera.h @@ -119,22 +119,20 @@ class GTSAM_EXPORT PinholeBase { /// @name Standard Constructors /// @{ - /** default constructor */ - PinholeBase() { - } + /// Default constructor + PinholeBase() {} - /** constructor with pose */ - explicit PinholeBase(const Pose3& pose) : - pose_(pose) { - } + /// Constructor with pose + explicit PinholeBase(const Pose3& pose) : pose_(pose) {} /// @} /// @name Advanced Constructors /// @{ - explicit PinholeBase(const Vector &v) : - pose_(Pose3::Expmap(v)) { - } + explicit PinholeBase(const Vector& v) : pose_(Pose3::Expmap(v)) {} + + /// Default destructor + virtual ~PinholeBase() = default; /// @} /// @name Testable diff --git a/gtsam/inference/Factor.h b/gtsam/inference/Factor.h index 57f95b0ea5..6ea81030a4 100644 --- a/gtsam/inference/Factor.h +++ b/gtsam/inference/Factor.h @@ -102,47 +102,52 @@ typedef FastSet FactorIndexSet; /// @} public: - /// @name Standard Interface - /// @{ + /// Default destructor + // public since it is required for boost serialization and static methods. + // virtual since it is public. + // http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-dtor-virtual + virtual ~Factor() = default; - /// First key - Key front() const { return keys_.front(); } + /// @name Standard Interface + /// @{ - /// Last key - Key back() const { return keys_.back(); } + /// First key + Key front() const { return keys_.front(); } - /// find - const_iterator find(Key key) const { return std::find(begin(), end(), key); } + /// Last key + Key back() const { return keys_.back(); } - /// Access the factor's involved variable keys - const KeyVector& keys() const { return keys_; } + /// find + const_iterator find(Key key) const { return std::find(begin(), end(), key); } - /** Iterator at beginning of involved variable keys */ - const_iterator begin() const { return keys_.begin(); } + /// Access the factor's involved variable keys + const KeyVector& keys() const { return keys_; } - /** Iterator at end of involved variable keys */ - const_iterator end() const { return keys_.end(); } + /** Iterator at beginning of involved variable keys */ + const_iterator begin() const { return keys_.begin(); } + + /** Iterator at end of involved variable keys */ + const_iterator end() const { return keys_.end(); } - /** + /** * @return the number of variables involved in this factor */ - size_t size() const { return keys_.size(); } - - /// @} + size_t size() const { return keys_.size(); } + /// @} - /// @name Testable - /// @{ + /// @name Testable + /// @{ - /// print - virtual void print( - const std::string& s = "Factor", - const KeyFormatter& formatter = DefaultKeyFormatter) const; + /// print + virtual void print( + const std::string& s = "Factor", + const KeyFormatter& formatter = DefaultKeyFormatter) const; - /// print only keys - virtual void printKeys( - const std::string& s = "Factor", - const KeyFormatter& formatter = DefaultKeyFormatter) const; + /// print only keys + virtual void printKeys( + const std::string& s = "Factor", + const KeyFormatter& formatter = DefaultKeyFormatter) const; protected: /// check equality diff --git a/gtsam/inference/FactorGraph.h b/gtsam/inference/FactorGraph.h index 90b9d7ef23..a9ca7f84d3 100644 --- a/gtsam/inference/FactorGraph.h +++ b/gtsam/inference/FactorGraph.h @@ -148,6 +148,10 @@ class FactorGraph { /// @} public: + /// Default destructor + // Public and virtual so boost serialization can call it. + virtual ~FactorGraph() = default; + /// @name Adding Single Factors /// @{ From cba8f626422b46336bfa9436cf3821dd313e265e Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 3 May 2021 17:01:26 -0400 Subject: [PATCH 2/2] fix unused warning --- gtsam/geometry/tests/testRot3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtsam/geometry/tests/testRot3.cpp b/gtsam/geometry/tests/testRot3.cpp index 889f685807..34f90c8cc5 100644 --- a/gtsam/geometry/tests/testRot3.cpp +++ b/gtsam/geometry/tests/testRot3.cpp @@ -825,7 +825,7 @@ TEST(Rot3, RQ_derivative) { const auto R = Rot3::RzRyRx(xyz).matrix(); const auto num = numericalDerivative11(RQ_proxy, R); Matrix39 calc; - RQ(R, calc).second; + RQ(R, calc); const auto err = vec_err.second; CHECK(assert_equal(num, calc, err));