replaced lambda with class plus functor
parent
7aab3796b0
commit
e3a28767ed
|
@ -165,13 +165,15 @@ inline Key Z(std::uint64_t j) { return Symbol('z', j); }
|
|||
|
||||
/** Generates symbol shorthands with alternative names different than the
|
||||
* one-letter predefined ones. */
|
||||
inline std::function<Key(std::uint64_t)> alternativeName(const char c) {
|
||||
return [c](std::uint64_t j) { return gtsam::Symbol(c, j); };
|
||||
}
|
||||
class SymbolGenerator {
|
||||
const char c_;
|
||||
public:
|
||||
SymbolGenerator(const char c) : c_(c) {}
|
||||
Symbol operator()(const std::uint64_t j) const { return Symbol(c_, j); }
|
||||
};
|
||||
}
|
||||
|
||||
/// traits
|
||||
template<> struct traits<Symbol> : public Testable<Symbol> {};
|
||||
|
||||
} // \ namespace gtsam
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ TEST(Key, KeySymbolConversion) {
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Key, SymbolAlternativeNames) {
|
||||
TEST(Key, SymbolGenerator) {
|
||||
const auto x1 = gtsam::symbol_shorthand::X(1);
|
||||
const auto v1 = gtsam::symbol_shorthand::V(1);
|
||||
const auto a1 = gtsam::symbol_shorthand::A(1);
|
||||
|
||||
const auto Z = gtsam::symbol_shorthand::alternativeName('x');
|
||||
const auto DZ = gtsam::symbol_shorthand::alternativeName('v');
|
||||
const auto DDZ = gtsam::symbol_shorthand::alternativeName('a');
|
||||
const auto Z = gtsam::symbol_shorthand::SymbolGenerator('x');
|
||||
const auto DZ = gtsam::symbol_shorthand::SymbolGenerator('v');
|
||||
const auto DDZ = gtsam::symbol_shorthand::SymbolGenerator('a');
|
||||
|
||||
const auto z1 = Z(1);
|
||||
const auto dz1 = DZ(1);
|
||||
|
@ -125,4 +125,3 @@ int main() {
|
|||
return TestRegistry::runAllTests(tr);
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
|
||||
|
|
Loading…
Reference in New Issue