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 2
2
3
3
#include < string>
4
4
5
+ #include " Enums.h"
6
+
5
7
namespace RhythmGameUtilities
6
8
{
7
9
@@ -35,7 +37,7 @@ std::string ToString(Difficulty difficulty)
35
37
case Expert:
36
38
return " Expert" ;
37
39
default :
38
- throw std::invalid_argument ( " Unknown Difficulty " );
40
+ unreachable ( );
39
41
}
40
42
}
41
43
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 2
2
3
3
#include < string>
4
4
5
+ #include " Enums.h"
6
+
5
7
namespace RhythmGameUtilities
6
8
{
7
9
@@ -28,7 +30,7 @@ std::string ToString(NamedSection namedSection)
28
30
case Events:
29
31
return " Events" ;
30
32
default :
31
- throw std::invalid_argument ( " Unknown NamedSection " );
33
+ unreachable ( );
32
34
}
33
35
}
34
36
Original file line number Diff line number Diff line change 2
2
3
3
#include < string>
4
4
5
+ #include " Enums.h"
6
+
5
7
namespace RhythmGameUtilities
6
8
{
7
9
@@ -35,7 +37,7 @@ std::string ToString(TypeCode typeCode)
35
37
case EventMarker:
36
38
return " E" ;
37
39
default :
38
- throw std::invalid_argument ( " Unknown TypeCode " );
40
+ unreachable ( );
39
41
}
40
42
}
41
43
You can’t perform that action at this time.
0 commit comments