File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed
include/RhythmGameUtilities/Enums Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 22
33#include < string>
44
5+ #include " Enums.h"
6+
57namespace RhythmGameUtilities
68{
79
@@ -35,7 +37,7 @@ std::string ToString(Difficulty difficulty)
3537 case Expert:
3638 return " Expert" ;
3739 default :
38- throw std::invalid_argument ( " Unknown Difficulty " );
40+ unreachable ( );
3941 }
4042}
4143
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < stdexcept>
4+
5+ [[noreturn]] inline void unreachable ()
6+ {
7+ #ifdef __GNUC__
8+ __builtin_unreachable ();
9+ #elif defined(_MSC_VER)
10+ __assume (0 );
11+ #else
12+ std::abort ();
13+ #endif
14+ }
Original file line number Diff line number Diff line change 22
33#include < string>
44
5+ #include " Enums.h"
6+
57namespace RhythmGameUtilities
68{
79
@@ -28,7 +30,7 @@ std::string ToString(NamedSection namedSection)
2830 case Events:
2931 return " Events" ;
3032 default :
31- throw std::invalid_argument ( " Unknown NamedSection " );
33+ unreachable ( );
3234 }
3335}
3436
Original file line number Diff line number Diff line change 22
33#include < string>
44
5+ #include " Enums.h"
6+
57namespace RhythmGameUtilities
68{
79
@@ -35,7 +37,7 @@ std::string ToString(TypeCode typeCode)
3537 case EventMarker:
3638 return " E" ;
3739 default :
38- throw std::invalid_argument ( " Unknown TypeCode " );
40+ unreachable ( );
3941 }
4042}
4143
You can’t perform that action at this time.
0 commit comments