Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU] Utilize c++17 fold expressions (#31333)

Egor Duplenskii73930198798d
diff --git a/src/plugins/intel_cpu/src/utils/debug_capabilities.h b/src/plugins/intel_cpu/src/utils/debug_capabilities.h
index 329258b56e8..2973908ffc7 100644
--- a/src/plugins/intel_cpu/src/utils/debug_capabilities.h
+++ b/src/plugins/intel_cpu/src/utils/debug_capabilities.h
@@ -172,12 +172,9 @@ std::ostream& operator<<(std::ostream& os, const PrintableVector<T>& vec) {
return os;
}
-static inline std::ostream& _write_all_to_stream(std::ostream& os) {
- return os;
-}
-template <typename T, typename... TS>
-static inline std::ostream& _write_all_to_stream(std::ostream& os, const T& arg, TS&&... args) {
- return ov::intel_cpu::_write_all_to_stream(os << arg, std::forward<TS>(args)...);
+template <typename... TS>
+static inline std::ostream& _write_all_to_stream(std::ostream& os, TS&&... args) {
+ return (os << ... << std::forward<TS>(args));
}
} // namespace ov::intel_cpu
diff --git a/src/plugins/intel_cpu/src/utils/general_utils.h b/src/plugins/intel_cpu/src/utils/general_utils.h
index f8e6be89433..d3c211c207b 100644
--- a/src/plugins/intel_cpu/src/utils/general_utils.h
+++ b/src/plugins/intel_cpu/src/utils/general_utils.h
@@ -37,24 +37,16 @@ inline T rnd_up(const T a, const U b) {
return div_up(a, b) * b;
}
-template <typename T, typename P>
-constexpr bool one_of(T val, P item) {
- return val == item;
+template <typename T, typename... Args>
+constexpr bool one_of(T val, Args... items) {
+ static_assert(sizeof...(Args) > 0, "'one_of' requires at least one item to compare against.");
+ return ((val == items) || ...);
}
-template <typename T, typename P, typename... Args>
-constexpr bool one_of(T val, P item, Args... item_others) {
- return val == item || one_of(val, item_others...);
-}
-
-template <typename T, typename P>
-constexpr bool everyone_is(T val, P item) {
- return val == item;
-}
-
-template <typename T, typename P, typename... Args>
-constexpr bool everyone_is(T val, P item, Args... item_others) {
- return val == item && everyone_is(val, item_others...);
+template <typename T, typename... Args>
+constexpr bool everyone_is(T val, Args... items) {
+ static_assert(sizeof...(Args) > 0, "'everyone_is' requires at least one item to compare against.");
+ return ((val == items) && ...);
}
constexpr bool implication(bool cause, bool cond) {