add default constructor for DiscreteKeys and minor improvements

release/4.3a0
Varun Agrawal 2021-12-16 12:30:52 -05:00
parent a4dab12bb0
commit 995e7a511f
1 changed files with 6 additions and 3 deletions

View File

@ -31,7 +31,7 @@ namespace gtsam {
* Key type for discrete conditionals * Key type for discrete conditionals
* Includes name and cardinality * Includes name and cardinality
*/ */
typedef std::pair<Key,size_t> DiscreteKey; using DiscreteKey = std::pair<Key,size_t>;
/// DiscreteKeys is a set of keys that can be assembled using the & operator /// DiscreteKeys is a set of keys that can be assembled using the & operator
struct DiscreteKeys: public std::vector<DiscreteKey> { struct DiscreteKeys: public std::vector<DiscreteKey> {
@ -39,13 +39,16 @@ namespace gtsam {
// Forward all constructors. // Forward all constructors.
using std::vector<DiscreteKey>::vector; using std::vector<DiscreteKey>::vector;
/// Constructor for serialization
GTSAM_EXPORT DiscreteKeys() : std::vector<DiscreteKey>::vector() {}
/// Construct from a key /// Construct from a key
DiscreteKeys(const DiscreteKey& key) { GTSAM_EXPORT DiscreteKeys(const DiscreteKey& key) {
push_back(key); push_back(key);
} }
/// Construct from a vector of keys /// Construct from a vector of keys
DiscreteKeys(const std::vector<DiscreteKey>& keys) : GTSAM_EXPORT DiscreteKeys(const std::vector<DiscreteKey>& keys) :
std::vector<DiscreteKey>(keys) { std::vector<DiscreteKey>(keys) {
} }