From a2c8f69c3deccb84b68611ae8aed20a1f64a5239 Mon Sep 17 00:00:00 2001 From: dellaert Date: Tue, 13 Jan 2015 20:26:48 +0100 Subject: [PATCH] Compile with latest Boost version on Mac (compile issues with boost::lambda) --- .cproject | 106 ++++++++++++-------- gtsam/inference/LabeledSymbol.cpp | 22 ++-- gtsam/inference/Symbol.cpp | 19 +--- gtsam/inference/tests/testKey.cpp | 17 +++- gtsam/inference/tests/testLabeledSymbol.cpp | 26 +++-- 5 files changed, 104 insertions(+), 86 deletions(-) diff --git a/.cproject b/.cproject index ff704cea8..ce0ab3c4c 100644 --- a/.cproject +++ b/.cproject @@ -584,6 +584,7 @@ make + tests/testBayesTree.run true false @@ -591,6 +592,7 @@ make + testBinaryBayesNet.run true false @@ -638,6 +640,7 @@ make + testSymbolicBayesNet.run true false @@ -645,6 +648,7 @@ make + tests/testSymbolicFactor.run true false @@ -652,6 +656,7 @@ make + testSymbolicFactorGraph.run true false @@ -667,6 +672,7 @@ make + tests/testBayesTree true false @@ -1098,6 +1104,7 @@ make + testErrors.run true false @@ -1327,6 +1334,46 @@ true true + + make + -j5 + testBTree.run + true + true + true + + + make + -j5 + testDSF.run + true + true + true + + + make + -j5 + testDSFMap.run + true + true + true + + + make + -j5 + testDSFVector.run + true + true + true + + + make + -j5 + testFixedVector.run + true + true + true + make -j2 @@ -1409,7 +1456,6 @@ make - testSimulated2DOriented.run true false @@ -1449,7 +1495,6 @@ make - testSimulated2D.run true false @@ -1457,7 +1502,6 @@ make - testSimulated3D.run true false @@ -1471,46 +1515,6 @@ true true - - make - -j5 - testBTree.run - true - true - true - - - make - -j5 - testDSF.run - true - true - true - - - make - -j5 - testDSFMap.run - true - true - true - - - make - -j5 - testDSFVector.run - true - true - true - - - make - -j5 - testFixedVector.run - true - true - true - make -j5 @@ -1551,6 +1555,14 @@ false true + + make + -j4 + testLabeledSymbol.run + true + true + true + make -j2 @@ -1768,6 +1780,7 @@ cpack + -G DEB true false @@ -1775,6 +1788,7 @@ cpack + -G RPM true false @@ -1782,6 +1796,7 @@ cpack + -G TGZ true false @@ -1789,6 +1804,7 @@ cpack + --config CPackSourceConfig.cmake true false @@ -2659,6 +2675,7 @@ make + testGraph.run true false @@ -2666,6 +2683,7 @@ make + testJunctionTree.run true false @@ -2673,6 +2691,7 @@ make + testSymbolicBayesNetB.run true false @@ -3272,7 +3291,6 @@ make - tests/testGaussianISAM2 true false diff --git a/gtsam/inference/LabeledSymbol.cpp b/gtsam/inference/LabeledSymbol.cpp index 7e573c13f..bd142a72c 100644 --- a/gtsam/inference/LabeledSymbol.cpp +++ b/gtsam/inference/LabeledSymbol.cpp @@ -17,12 +17,8 @@ #include -#include #include -#include -#include -#include -#include +#include #include @@ -111,23 +107,21 @@ bool LabeledSymbol::operator!=(gtsam::Key comp) const { } /* ************************************************************************* */ +static LabeledSymbol make(gtsam::Key key) { return LabeledSymbol(key);} + boost::function LabeledSymbol::TypeTest(unsigned char c) { - namespace bl = boost::lambda; - return bl::bind(&LabeledSymbol::chr, bl::bind(bl::constructor(), bl::_1)) == c; + return bind(&LabeledSymbol::chr, bind(make, _1)) == c; } -/* ************************************************************************* */ boost::function LabeledSymbol::LabelTest(unsigned char label) { - namespace bl = boost::lambda; - return bl::bind(&LabeledSymbol::label, bl::bind(bl::constructor(), bl::_1)) == label; + return bind(&LabeledSymbol::label, bind(make, _1)) == label; } -/* ************************************************************************* */ boost::function LabeledSymbol::TypeLabelTest(unsigned char c, unsigned char label) { - namespace bl = boost::lambda; - return bl::bind(&LabeledSymbol::chr, bl::bind(bl::constructor(), bl::_1)) == c && - bl::bind(&LabeledSymbol::label, bl::bind(bl::constructor(), bl::_1)) == label; + return bind(&LabeledSymbol::chr, bind(make, _1)) == c && + bind(&LabeledSymbol::label, bind(make, _1)) == label; } +/* ************************************************************************* */ } // \namespace gtsam diff --git a/gtsam/inference/Symbol.cpp b/gtsam/inference/Symbol.cpp index 37a6d0897..f8b37d429 100644 --- a/gtsam/inference/Symbol.cpp +++ b/gtsam/inference/Symbol.cpp @@ -18,19 +18,8 @@ #include -#include #include -#include -#include -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-variable" -#endif -#include -#include -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#include #include #include @@ -71,10 +60,10 @@ Symbol::operator std::string() const { return str(boost::format("%c%d") % c_ % j_); } +static Symbol make(gtsam::Key key) { return Symbol(key);} + boost::function Symbol::ChrTest(unsigned char c) { - namespace bl = boost::lambda; - return bl::bind(&Symbol::chr, bl::bind(bl::constructor(), bl::_1)) - == c; + return bind(&Symbol::chr, bind(make, _1)) == c; } } // namespace gtsam diff --git a/gtsam/inference/tests/testKey.cpp b/gtsam/inference/tests/testKey.cpp index 5b57096cb..1033c0cc9 100644 --- a/gtsam/inference/tests/testKey.cpp +++ b/gtsam/inference/tests/testKey.cpp @@ -14,14 +14,14 @@ * @author Alex Cunningham */ -#include // for operator += -using namespace boost::assign; - -#include +#include #include #include -#include +#include + +#include // for operator += +using namespace boost::assign; using namespace std; using namespace gtsam; @@ -65,6 +65,13 @@ TEST(Key, KeySymbolEncoding) { EXPECT(assert_equal(symbol, Symbol(key))); } +/* ************************************************************************* */ +TEST(Key, ChrTest) { + Key key = Symbol('c',3); + EXPECT(Symbol::ChrTest('c')(key)); + EXPECT(!Symbol::ChrTest('d')(key)); +} + /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); } /* ************************************************************************* */ diff --git a/gtsam/inference/tests/testLabeledSymbol.cpp b/gtsam/inference/tests/testLabeledSymbol.cpp index 07727c8dc..18216453d 100644 --- a/gtsam/inference/tests/testLabeledSymbol.cpp +++ b/gtsam/inference/tests/testLabeledSymbol.cpp @@ -14,20 +14,19 @@ * @author Alex Cunningham */ -#include // for operator += -using namespace boost::assign; - -#include +#include #include #include -#include - +#include +#include // for operator += + +using namespace boost::assign; using namespace std; using namespace gtsam; /* ************************************************************************* */ -TEST( testLabeledSymbol, KeyLabeledSymbolConversion ) { +TEST(LabeledSymbol, KeyLabeledSymbolConversion ) { LabeledSymbol expected('x', 'A', 4); Key key(expected); LabeledSymbol actual(key); @@ -36,7 +35,7 @@ TEST( testLabeledSymbol, KeyLabeledSymbolConversion ) { } /* ************************************************************************* */ -TEST( testLabeledSymbol, KeyLabeledSymbolEncoding ) { +TEST(LabeledSymbol, KeyLabeledSymbolEncoding ) { // Test encoding of LabeledSymbol <-> size_t <-> string // Encoding scheme: @@ -69,6 +68,17 @@ TEST( testLabeledSymbol, KeyLabeledSymbolEncoding ) { } } +/* ************************************************************************* */ +TEST(LabeledSymbol, ChrTest) { + Key key = LabeledSymbol('c','A',3); + EXPECT(LabeledSymbol::TypeTest('c')(key)); + EXPECT(!LabeledSymbol::TypeTest('d')(key)); + EXPECT(LabeledSymbol::LabelTest('A')(key)); + EXPECT(!LabeledSymbol::LabelTest('D')(key)); + EXPECT(LabeledSymbol::TypeLabelTest('c','A')(key)); + EXPECT(!LabeledSymbol::TypeLabelTest('c','D')(key)); +} + /* ************************************************************************* */ int main() { TestResult tr; return TestRegistry::runAllTests(tr); } /* ************************************************************************* */