From b9ceca7dc6b506c4fc11e52ff48a91a8e90b7929 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sat, 31 Oct 2009 14:11:48 +0000 Subject: [PATCH] Templated binary predicate [equals] for use with STL's equal(...) --- cpp/Testable.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cpp/Testable.h b/cpp/Testable.h index 7a0ce98b3..d69021b92 100644 --- a/cpp/Testable.h +++ b/cpp/Testable.h @@ -8,6 +8,8 @@ #pragma once +#include + namespace gtsam { /** @@ -49,4 +51,21 @@ namespace gtsam { return false; } + /** + * Template to create a binary predicate + */ + template + bool equals(const V& expected, const V& actual, double tol = 1e-9) { + return (actual.equals(expected, tol)); + } + + /** + * Binary predicate on shared pointers + */ + template + bool equals_star(const boost::shared_ptr& expected, + const boost::shared_ptr& actual, double tol = 1e-9) { + return (actual->equals(*expected, tol)); + } + } // gtsam