File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -1400,16 +1400,17 @@ const char *StrErrorDumper::Get(int errornum)
1400
1400
return this ->buf ;
1401
1401
}
1402
1402
#else
1403
+ struct StrErrorRHelper {
1404
+ static bool Success (char *result) { return true ; } // /< GNU-specific
1405
+ static bool Success (int result) { return result == 0 ; } // /< XSI-compliant
1406
+
1407
+ static const char *GetString (char *result, const char *buffer) { return result; } // /< GNU-specific
1408
+ static const char *GetString (int result, const char *buffer) { return buffer; } // /< XSI-compliant
1409
+ };
1410
+
1403
1411
auto result = strerror_r (errornum, this ->buf , lengthof (this ->buf ));
1404
- static_assert (std::is_same_v<decltype (result), char *> || std::is_same_v<decltype (result), int >);
1405
- if constexpr (std::is_same_v<decltype (result), char *>) {
1406
- /* GNU-specific */
1407
- return result;
1408
- } else {
1409
- /* XSI-compliant */
1410
- if (result == 0 ) {
1411
- return this ->buf ;
1412
- }
1412
+ if (StrErrorRHelper::Success (result)) {
1413
+ return StrErrorRHelper::GetString (result, this ->buf );
1413
1414
}
1414
1415
#endif
1415
1416
You can’t perform that action at this time.
0 commit comments