noexcept fix for visual studio

This commit is contained in:
g 2017-03-17 14:13:11 -07:00
parent 0fdb1b910c
commit 5dc3221974
3 changed files with 34 additions and 28 deletions

View File

@ -17,7 +17,7 @@ Commit messages should be in the imperative mood, as described in the [Git contr
# Tests # Tests
Please verify the tests pass by running the target `tests/run_tests`. Please verify the tests pass by running the target `test/run-tests`.
If you are adding functionality, add tests accordingly. If you are adding functionality, add tests accordingly.

View File

@ -7,6 +7,12 @@
#pragma once #pragma once
#endif #endif
#ifndef _MSC_VER
#define NOEXCEPT noexcept
#else
#define NOEXCEPT _NOEXCEPT
#endif
#include "yaml-cpp/mark.h" #include "yaml-cpp/mark.h"
#include "yaml-cpp/traits.h" #include "yaml-cpp/traits.h"
#include <sstream> #include <sstream>
@ -112,7 +118,7 @@ class YAML_CPP_API Exception : public std::runtime_error {
public: public:
Exception(const Mark& mark_, const std::string& msg_) Exception(const Mark& mark_, const std::string& msg_)
: std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
virtual ~Exception() noexcept; virtual ~Exception() NOEXCEPT;
Exception(const Exception&) = default; Exception(const Exception&) = default;
@ -138,7 +144,7 @@ class YAML_CPP_API ParserException : public Exception {
ParserException(const Mark& mark_, const std::string& msg_) ParserException(const Mark& mark_, const std::string& msg_)
: Exception(mark_, msg_) {} : Exception(mark_, msg_) {}
ParserException(const ParserException&) = default; ParserException(const ParserException&) = default;
virtual ~ParserException() noexcept; virtual ~ParserException() NOEXCEPT;
}; };
class YAML_CPP_API RepresentationException : public Exception { class YAML_CPP_API RepresentationException : public Exception {
@ -146,7 +152,7 @@ class YAML_CPP_API RepresentationException : public Exception {
RepresentationException(const Mark& mark_, const std::string& msg_) RepresentationException(const Mark& mark_, const std::string& msg_)
: Exception(mark_, msg_) {} : Exception(mark_, msg_) {}
RepresentationException(const RepresentationException&) = default; RepresentationException(const RepresentationException&) = default;
virtual ~RepresentationException() noexcept; virtual ~RepresentationException() NOEXCEPT;
}; };
// representation exceptions // representation exceptions
@ -155,7 +161,7 @@ class YAML_CPP_API InvalidScalar : public RepresentationException {
InvalidScalar(const Mark& mark_) InvalidScalar(const Mark& mark_)
: RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
InvalidScalar(const InvalidScalar&) = default; InvalidScalar(const InvalidScalar&) = default;
virtual ~InvalidScalar() noexcept; virtual ~InvalidScalar() NOEXCEPT;
}; };
class YAML_CPP_API KeyNotFound : public RepresentationException { class YAML_CPP_API KeyNotFound : public RepresentationException {
@ -165,7 +171,7 @@ class YAML_CPP_API KeyNotFound : public RepresentationException {
: RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) { : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {
} }
KeyNotFound(const KeyNotFound&) = default; KeyNotFound(const KeyNotFound&) = default;
virtual ~KeyNotFound() noexcept; virtual ~KeyNotFound() NOEXCEPT;
}; };
template <typename T> template <typename T>
@ -173,7 +179,7 @@ class YAML_CPP_API TypedKeyNotFound : public KeyNotFound {
public: public:
TypedKeyNotFound(const Mark& mark_, const T& key_) TypedKeyNotFound(const Mark& mark_, const T& key_)
: KeyNotFound(mark_, key_), key(key_) {} : KeyNotFound(mark_, key_), key(key_) {}
virtual ~TypedKeyNotFound() noexcept {} virtual ~TypedKeyNotFound() NOEXCEPT {}
T key; T key;
}; };
@ -189,7 +195,7 @@ class YAML_CPP_API InvalidNode : public RepresentationException {
InvalidNode() InvalidNode()
: RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {} : RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {}
InvalidNode(const InvalidNode&) = default; InvalidNode(const InvalidNode&) = default;
virtual ~InvalidNode() noexcept; virtual ~InvalidNode() NOEXCEPT;
}; };
class YAML_CPP_API BadConversion : public RepresentationException { class YAML_CPP_API BadConversion : public RepresentationException {
@ -197,7 +203,7 @@ class YAML_CPP_API BadConversion : public RepresentationException {
explicit BadConversion(const Mark& mark_) explicit BadConversion(const Mark& mark_)
: RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {} : RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {}
BadConversion(const BadConversion&) = default; BadConversion(const BadConversion&) = default;
virtual ~BadConversion() noexcept; virtual ~BadConversion() NOEXCEPT;
}; };
template <typename T> template <typename T>
@ -211,7 +217,7 @@ class YAML_CPP_API BadDereference : public RepresentationException {
BadDereference() BadDereference()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {}
BadDereference(const BadDereference&) = default; BadDereference(const BadDereference&) = default;
virtual ~BadDereference() noexcept; virtual ~BadDereference() NOEXCEPT;
}; };
class YAML_CPP_API BadSubscript : public RepresentationException { class YAML_CPP_API BadSubscript : public RepresentationException {
@ -219,7 +225,7 @@ class YAML_CPP_API BadSubscript : public RepresentationException {
BadSubscript() BadSubscript()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {}
BadSubscript(const BadSubscript&) = default; BadSubscript(const BadSubscript&) = default;
virtual ~BadSubscript() noexcept; virtual ~BadSubscript() NOEXCEPT;
}; };
class YAML_CPP_API BadPushback : public RepresentationException { class YAML_CPP_API BadPushback : public RepresentationException {
@ -227,7 +233,7 @@ class YAML_CPP_API BadPushback : public RepresentationException {
BadPushback() BadPushback()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {}
BadPushback(const BadPushback&) = default; BadPushback(const BadPushback&) = default;
virtual ~BadPushback() noexcept; virtual ~BadPushback() NOEXCEPT;
}; };
class YAML_CPP_API BadInsert : public RepresentationException { class YAML_CPP_API BadInsert : public RepresentationException {
@ -235,7 +241,7 @@ class YAML_CPP_API BadInsert : public RepresentationException {
BadInsert() BadInsert()
: RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {} : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {}
BadInsert(const BadInsert&) = default; BadInsert(const BadInsert&) = default;
virtual ~BadInsert() noexcept; virtual ~BadInsert() NOEXCEPT;
}; };
class YAML_CPP_API EmitterException : public Exception { class YAML_CPP_API EmitterException : public Exception {
@ -243,14 +249,14 @@ class YAML_CPP_API EmitterException : public Exception {
EmitterException(const std::string& msg_) EmitterException(const std::string& msg_)
: Exception(Mark::null_mark(), msg_) {} : Exception(Mark::null_mark(), msg_) {}
EmitterException(const EmitterException&) = default; EmitterException(const EmitterException&) = default;
virtual ~EmitterException() noexcept; virtual ~EmitterException() NOEXCEPT;
}; };
class YAML_CPP_API BadFile : public Exception { class YAML_CPP_API BadFile : public Exception {
public: public:
BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {} BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {}
BadFile(const BadFile&) = default; BadFile(const BadFile&) = default;
virtual ~BadFile() noexcept; virtual ~BadFile() NOEXCEPT;
}; };
} }

View File

@ -3,17 +3,17 @@
namespace YAML { namespace YAML {
// These destructors are defined out-of-line so the vtable is only emitted once. // These destructors are defined out-of-line so the vtable is only emitted once.
Exception::~Exception() noexcept {} Exception::~Exception() NOEXCEPT {}
ParserException::~ParserException() noexcept {} ParserException::~ParserException() NOEXCEPT {}
RepresentationException::~RepresentationException() noexcept {} RepresentationException::~RepresentationException() NOEXCEPT {}
InvalidScalar::~InvalidScalar() noexcept {} InvalidScalar::~InvalidScalar() NOEXCEPT {}
KeyNotFound::~KeyNotFound() noexcept {} KeyNotFound::~KeyNotFound() NOEXCEPT {}
InvalidNode::~InvalidNode() noexcept {} InvalidNode::~InvalidNode() NOEXCEPT {}
BadConversion::~BadConversion() noexcept {} BadConversion::~BadConversion() NOEXCEPT {}
BadDereference::~BadDereference() noexcept {} BadDereference::~BadDereference() NOEXCEPT {}
BadSubscript::~BadSubscript() noexcept {} BadSubscript::~BadSubscript() NOEXCEPT {}
BadPushback::~BadPushback() noexcept {} BadPushback::~BadPushback() NOEXCEPT {}
BadInsert::~BadInsert() noexcept {} BadInsert::~BadInsert() NOEXCEPT {}
EmitterException::~EmitterException() noexcept {} EmitterException::~EmitterException() NOEXCEPT {}
BadFile::~BadFile() noexcept {} BadFile::~BadFile() NOEXCEPT {}
} }