Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh committed Dec 3, 2023
1 parent dba8195 commit 7f67e03
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/safe_convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ std::string number_to_string(U value) {
* int integer = safe_convert<int>("invalid", __FUNCTION__, -1); // Returns -1
*/
template <typename T, typename U>
requires std::is_arithmetic_v<T> && !std::is_enum_v<U> || !std::is_enum_v<U> && std::is_same_v<T, std::string>
T safe_convert(U value, std::string_view callerName = "Name not defined", T defaultValue = get_default_value<T>()) {
requires (std::is_arithmetic_v<T> && !std::is_enum_v<U>) || (!std::is_enum_v<U> && std::is_same_v<T, std::string>)
T safe_convert(U value, std::string_view callerName = "Name not defined", T defaultValue = get_default_value<T>()) {
static_assert(std::is_arithmetic_v<T> || std::is_same_v<T, std::string>, "T must be an arithmetic type or string.");
try {
// Direct conversion if types are the same
Expand Down Expand Up @@ -178,7 +178,7 @@ template <typename T, typename U>
* MyEnum e3 = safe_convert<MyEnum>(10, "myFunction", MyEnum::C); // Returns MyEnum::C as default
*/
template <typename T, typename U>
requires std::is_enum_v<T>
requires std::is_enum_v<T>
T safe_convert(U value, std::string_view callerName = "Name not defined", T defaultValue = T()) {
try {
if constexpr (std::is_same_v<U, T>) {
Expand Down Expand Up @@ -211,7 +211,7 @@ T safe_convert(U value, std::string_view callerName = "Name not defined", T defa
* unsigned int uval = safe_convert<unsigned int>(MyEnum::X, "callerFunc", 0);
*/
template <typename Target, typename Source>
requires std::is_enum_v<Source> && std::is_arithmetic_v<Target>
requires std::is_enum_v<Source> && std::is_arithmetic_v<Target>
Target safe_convert(Source sourceValue, std::string_view callerName = "Name not defined", Target defaultValue = Target()) {
try {
if constexpr (std::is_same_v<Source, Target>) {
Expand Down

0 comments on commit 7f67e03

Please sign in to comment.