Skip to content

Commit

Permalink
Disable 4251 and 4275, pop warnings, and use const char * for ctor
Browse files Browse the repository at this point in the history
Signed-off-by: Zachary Michaels <[email protected]>
  • Loading branch information
zmichaels11 committed Jan 23, 2020
1 parent c3db1bc commit f1f385c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/rcpputils/asserts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// This should be fine since its extending an STL class.
#ifdef _WIN32
# pragma warning(push)
# pragma warning(disable:4251)
# pragma warning(disable:4275)
#endif

Expand All @@ -37,19 +38,17 @@ class RCPPUTILS_PUBLIC AssertionException : public std::exception
std::string msg_;

public:
explicit AssertionException(const std::string & msg)
: msg_{msg} {}
explicit AssertionException(const char * msg);

virtual const char * what() const throw();
};

class RCPPUTILS_PUBLIC IllegalStateException : public std::exception
class IllegalStateException : public std::exception
{
std::string msg_;

public:
explicit IllegalStateException(const std::string & msg)
: msg_{msg} {}
explicit IllegalStateException(const char * msg);

virtual const char * what() const throw();
};
Expand Down Expand Up @@ -100,4 +99,8 @@ inline void assert_true(bool condition)
}
} // namespace rcpputils

#ifdef _WIN32
# pragma warning(pop)
#endif

#endif // RCPPUTILS__ASSERTS_HPP_
10 changes: 10 additions & 0 deletions src/asserts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@

namespace rcpputils
{
AssertionException::AssertionException(const char * msg)
{
msg_ = msg;
}

const char * AssertionException::what() const throw()
{
return msg_.c_str();
}

IllegalStateException::IllegalStateException(const char * msg)
{
msg_ = msg;
}

const char * IllegalStateException::what() const throw()
{
return msg_.c_str();
Expand Down

0 comments on commit f1f385c

Please sign in to comment.