Skip to content

Commit

Permalink
gtsam: backport a patch for C++17 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Valgur committed Jun 15, 2023
1 parent b0d6a4a commit eb041bc
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
9 changes: 6 additions & 3 deletions recipes/gtsam/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ patches:
- patch_file: "patches/4.1.1-0003-macos-rpath.patch"
patch_description: "Relocatable shared libs on Apple OS"
patch_type: "conan"
- patch_file: "patches/4.0.2-0003-cmake-project.patch"
- patch_file: "patches/4.0.2-0004-cmake-project.patch"
patch_description: "CMake: move project() after cmake_minimum_required()"
patch_type: "conan"
"4.0.3":
Expand All @@ -32,7 +32,7 @@ patches:
- patch_file: "patches/4.0.3-0003-macos-rpath.patch"
patch_description: "Relocatable shared libs on Apple OS"
patch_type: "conan"
- patch_file: "patches/4.0.2-0003-cmake-project.patch"
- patch_file: "patches/4.0.2-0004-cmake-project.patch"
patch_description: "CMake: move project() after cmake_minimum_required()"
patch_type: "conan"
"4.0.2":
Expand All @@ -45,6 +45,9 @@ patches:
- patch_file: "patches/4.0.2-0003-macos-rpath.patch"
patch_description: "Relocatable shared libs on Apple OS"
patch_type: "conan"
- patch_file: "patches/4.0.2-0003-cmake-project.patch"
- patch_file: "patches/4.0.2-0004-cmake-project.patch"
patch_description: "CMake: move project() after cmake_minimum_required()"
patch_type: "conan"
- patch_file: "patches/4.0.2-0005-replace-ptr_fun.patch"
patch_description: "Replace deprecated `ptr_fun` with lambda expression for C++17"
patch_type: "portability"
55 changes: 55 additions & 0 deletions recipes/gtsam/all/patches/4.0.2-0005-replace-ptr_fun.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 4a1491876d5a96ea791c0e17204ace05f6eb206a Mon Sep 17 00:00:00 2001
From: Frank Dellaert <dellaert@gmail.com>
Date: Sat, 12 Oct 2019 14:14:10 -0400
Subject: [PATCH] Replace deprecated `ptr_fun` with lambda expression

---
gtsam/linear/GaussianBayesNet.cpp | 12 ++++++------
gtsam/linear/GaussianBayesTree.cpp | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gtsam/linear/GaussianBayesNet.cpp b/gtsam/linear/GaussianBayesNet.cpp
index bc96452b92..e9938ceb65 100644
--- a/gtsam/linear/GaussianBayesNet.cpp
+++ b/gtsam/linear/GaussianBayesNet.cpp
@@ -187,16 +187,16 @@ namespace gtsam {
}

/* ************************************************************************* */
- double GaussianBayesNet::logDeterminant() const
- {
+ double GaussianBayesNet::logDeterminant() const {
double logDet = 0.0;
- for(const sharedConditional& cg: *this) {
- if(cg->get_model()) {
+ for (const sharedConditional& cg : *this) {
+ if (cg->get_model()) {
Vector diag = cg->R().diagonal();
cg->get_model()->whitenInPlace(diag);
- logDet += diag.unaryExpr(ptr_fun<double,double>(log)).sum();
+ logDet += diag.unaryExpr([](double x) { return log(x); }).sum();
} else {
- logDet += cg->R().diagonal().unaryExpr(ptr_fun<double,double>(log)).sum();
+ logDet +=
+ cg->R().diagonal().unaryExpr([](double x) { return log(x); }).sum();
}
}
return logDet;
diff --git a/gtsam/linear/GaussianBayesTree.cpp b/gtsam/linear/GaussianBayesTree.cpp
index 8d0fafb618..13c19bce65 100644
--- a/gtsam/linear/GaussianBayesTree.cpp
+++ b/gtsam/linear/GaussianBayesTree.cpp
@@ -40,11 +40,11 @@ namespace gtsam {
parentSum += clique->conditional()
->R()
.diagonal()
- .unaryExpr(std::ptr_fun<double, double>(log))
+ .unaryExpr([](double x) { return log(x); })
.sum();
return 0;
}
- }
+ } // namespace internal

/* ************************************************************************* */
bool GaussianBayesTree::equals(const This& other, double tol) const

0 comments on commit eb041bc

Please sign in to comment.