Skip to content

Commit

Permalink
Some MSVC compiler bug has been fixed, remove workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Oct 2, 2023
1 parent 7e5cc4a commit 4355ad8
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/tech/include/cct_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace cct {

/// Implementation of a simple string (untruncated) storage with noexcept constructors and what() method.
/// Implementation of a simple string (un-truncated) storage with noexcept constructors and what() method.
/// To be constructed from a 'const char []', it needs to be small enough to fill in the buffer. For custom, longer
/// error messages, the constructor from the rvalue of a string should be used instead.
class exception : public std::exception {
Expand All @@ -31,18 +31,10 @@ class exception : public std::exception {

explicit exception(string&& str) noexcept(std::is_nothrow_move_constructible_v<string>) : _data(std::move(str)) {}

#ifdef CCT_MSVC
// MSVC bug: https://developercommunity.visualstudio.com/t/using-fmtlib-on-a-custom-exceptions-constructor-pa/1673659
// do not use fmt for building an exception waiting for the bug to be fixed...
// Exception message will be incorrect.
template <typename... Args>
explicit exception(std::string_view fmt, Args&&...) : _data(std::in_place_type<string>, fmt) {}
#else
template <typename... Args>
explicit exception(format_string<Args...> fmt, Args&&... args) : _data(std::in_place_type<string>) {
cct::format_to(std::back_inserter(std::get<1>(_data)), fmt, std::forward<Args>(args)...);
}
#endif

const char* what() const noexcept override {
switch (_data.index()) {
Expand Down

0 comments on commit 4355ad8

Please sign in to comment.