pad as<array..> with 0s in case size is smaller than expected
This commit is contained in:
parent
0e0788d764
commit
cef817a10c
@ -13,6 +13,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "yaml-cpp/binary.h"
|
#include "yaml-cpp/binary.h"
|
||||||
#include "yaml-cpp/node/impl.h"
|
#include "yaml-cpp/node/impl.h"
|
||||||
@ -284,12 +285,15 @@ struct convert<std::array<T, N>> {
|
|||||||
rhs[i] = node[i].as<T>();
|
rhs[i] = node[i].as<T>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
for (auto i = node.size(); i < N; i++) {
|
||||||
|
std::memset(&rhs[i], 0, sizeof(T));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool isNodeValid(const Node& node) {
|
static bool isNodeValid(const Node& node) {
|
||||||
return node.IsSequence() && node.size() == N;
|
return node.IsSequence() && node.size() <= N;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user