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:
@@ -7,14 +7,17 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "yaml-cpp/noexcept.h"
|
||||
#include "stream.h"
|
||||
#include <cstddef>
|
||||
|
||||
namespace YAML {
|
||||
|
||||
class StreamCharSource {
|
||||
public:
|
||||
StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {}
|
||||
StreamCharSource(const StreamCharSource& source) = default;
|
||||
StreamCharSource(StreamCharSource&&) = default;
|
||||
StreamCharSource(StreamCharSource&&) YAML_CPP_NOEXCEPT = default;
|
||||
StreamCharSource& operator=(const StreamCharSource&) = delete;
|
||||
StreamCharSource& operator=(StreamCharSource&&) = delete;
|
||||
~StreamCharSource() = default;
|
||||
@@ -37,7 +40,7 @@ inline StreamCharSource::operator bool() const {
|
||||
inline const StreamCharSource StreamCharSource::operator+(int i) const {
|
||||
StreamCharSource source(*this);
|
||||
if (static_cast<int>(source.m_offset) + i >= 0)
|
||||
source.m_offset += i;
|
||||
source.m_offset += static_cast<std::size_t>(i);
|
||||
else
|
||||
source.m_offset = 0;
|
||||
return source;
|
||||
|
Reference in New Issue
Block a user