Merge pull request #629 from borglab/feature/constexpr-symbolgenerator
SymbolGenerator: add chr() and made constexpr-capablerelease/4.3a0
commit
13db697bed
|
@ -167,10 +167,11 @@ inline Key Z(std::uint64_t j) { return Symbol('z', j); }
|
|||
/** Generates symbol shorthands with alternative names different than the
|
||||
* one-letter predefined ones. */
|
||||
class SymbolGenerator {
|
||||
const char c_;
|
||||
const unsigned char c_;
|
||||
public:
|
||||
SymbolGenerator(const char c) : c_(c) {}
|
||||
constexpr SymbolGenerator(const unsigned char c) : c_(c) {}
|
||||
Symbol operator()(const std::uint64_t j) const { return Symbol(c_, j); }
|
||||
constexpr unsigned char chr() const { return c_; }
|
||||
};
|
||||
|
||||
/// traits
|
||||
|
|
|
@ -59,6 +59,12 @@ TEST(Key, SymbolGenerator) {
|
|||
EXPECT(assert_equal(a1, ddz1));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Key, SymbolGeneratorConstexpr) {
|
||||
constexpr auto Z = gtsam::SymbolGenerator('x');
|
||||
EXPECT(assert_equal(Z.chr(), 'x'));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<int KeySize>
|
||||
Key KeyTestValue();
|
||||
|
|
Loading…
Reference in New Issue