mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-10 04:51:17 +00:00
Make SettingChange and StreamCharSourcemove constructors and assignment operators noexcept (#808)
The explicitly defaulted or implemented move constructors and assignment operators are made "noexcept". Bugfix: * src/stream.cpp Stream::Stream() char_traits::int_type intro[4] is now aggregate-initialized (to zero) to avoid UB. Minor changes: * Using std::isinf() and std::signbit() instead of comparing for equality with infinity. * src/streamcharsource.h: Added #include "stream.h". * src/stream.h: Forward declaring "class StreamCharSource". * Some implicit casting changed into static_cast's. Signed-off-by: Ted Lyngmo <ted@lyncon.se>
This commit is contained in:
@@ -164,13 +164,12 @@ inline Emitter& Emitter::WriteStreamable(T value) {
|
||||
std::isnan(value)) {
|
||||
special = true;
|
||||
stream << ".nan";
|
||||
} else if (std::numeric_limits<T>::has_infinity) {
|
||||
if (value == std::numeric_limits<T>::infinity()) {
|
||||
special = true;
|
||||
stream << ".inf";
|
||||
} else if (value == -std::numeric_limits<T>::infinity()) {
|
||||
special = true;
|
||||
} else if (std::numeric_limits<T>::has_infinity && std::isinf(value)) {
|
||||
special = true;
|
||||
if (std::signbit(value)) {
|
||||
stream << "-.inf";
|
||||
} else {
|
||||
stream << ".inf";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ struct get_idx<Key,
|
||||
static node* get(std::vector<node*>& sequence, const Key& key,
|
||||
shared_memory_holder pMemory) {
|
||||
if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined()))
|
||||
return 0;
|
||||
return nullptr;
|
||||
if (key == sequence.size())
|
||||
sequence.push_back(&pMemory->create_node());
|
||||
return sequence[key];
|
||||
|
Reference in New Issue
Block a user