Commit e51b17f4 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

parent b19c8721
......@@ -175,8 +175,6 @@ if(NOT DEFINED CAF_USE_STD_FORMAT)
message(STATUS "Disable std::format support: NOT available")
endif()
endif()
else()
set(CAF_USE_STD_FORMAT OFF CACHE BOOL "Enable std::format support" FORCE)
endif()
# -- export internal target (may be useful for re-using compiler flags) --------
......
......@@ -52,9 +52,7 @@ using format_arg = std::variant<bool, char, int64_t, uint64_t, double,
template <class T>
format_arg make_format_arg(const T& arg) {
if constexpr (std::is_same_v<T, bool>) {
return format_arg{arg};
} else if constexpr (std::is_same_v<T, char>) {
if constexpr (is_one_of_v<T, bool, char, const char*, std::string_view>) {
return format_arg{arg};
} else if constexpr (std::is_integral_v<T>) {
if constexpr (std::is_signed_v<T>) {
......@@ -64,12 +62,8 @@ format_arg make_format_arg(const T& arg) {
}
} else if constexpr (std::is_floating_point_v<T>) {
return format_arg{static_cast<double>(arg)};
} else if constexpr (std::is_same_v<T, const char*>) {
return format_arg{arg};
} else if constexpr (std::is_same_v<T, std::string>) {
return format_arg{std::string_view{arg}};
} else if constexpr (std::is_same_v<T, std::string_view>) {
return format_arg{arg};
} else {
static_assert(std::is_pointer_v<T>, "unsupported argument type");
return format_arg{static_cast<const void*>(arg)};
......
......@@ -21,4 +21,7 @@ struct is_one_of<T, T, Ts...> : std::true_type {};
template <class T, class U, class... Ts>
struct is_one_of<T, U, Ts...> : is_one_of<T, Ts...> {};
template <class T, class... Ts>
constexpr bool is_one_of_v = (std::is_same_v<T, Ts> || ...);
} // namespace caf::detail
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment