@@ -241,28 +241,38 @@ namespace xtd {
241241 // / @param source A sequence of xtd::decimal values to calculate the average of.
242242 // / @return The average of the sequence of values.
243243 // / @exception xtd::invalid_operation_exception `source` contains no elements.
244- [[nodiscard]] static auto average (const ienumerable<xtd::decimal>& source) -> xtd::decimal;
244+ template <xtd::forward_iterable source_t >
245+ requires xtd::real_decimal<typename xtd::raw_type<source_t >::value_type>
246+ [[nodiscard]] static auto average (source_t && source) -> xtd::decimal;
245247 // / @brief Computes the average of a sequence of double values.
246248 // / @param source A sequence of double values to calculate the average of.
247249 // / @return The average of the sequence of values.
248250 // / @exception xtd::invalid_operation_exception `source` contains no elements.
249- [[nodiscard]] static auto average (const ienumerable<double >& source) -> double;
251+ template <xtd::forward_iterable source_t >
252+ requires xtd::real_double<typename xtd::raw_type<source_t >::value_type>
253+ [[nodiscard]] static auto average (source_t && source) -> double;
250254 // / @brief Computes the average of a sequence of float values.
251255 // / @param source A sequence of float values to calculate the average of.
252256 // / @return The average of the sequence of values.
253257 // / @exception xtd::invalid_operation_exception `source` contains no elements.
254- [[nodiscard]] static auto average (const ienumerable<float >& source) -> float;
258+ template <xtd::forward_iterable source_t >
259+ requires xtd::real_single<typename xtd::raw_type<source_t >::value_type>
260+ [[nodiscard]] static auto average (source_t && source) -> xtd::single;
255261 // / @brief Computes the average of a sequence of xtd::int32 values.
256262 // / @param source A sequence of xtd::int32 values to calculate the average of.
257263 // / @return The average of the sequence of values.
258264 // / @exception xtd::invalid_operation_exception `source` contains no elements.
259- [[nodiscard]] static auto average (const ienumerable<xtd::int32>& source) -> double;
265+ template <xtd::forward_iterable source_t >
266+ requires xtd::signed_integer_32<typename xtd::raw_type<source_t >::value_type>
267+ [[nodiscard]] static auto average (source_t && source) -> double;
260268 // / @brief Computes the average of a sequence of xtd::int64 values.
261269 // / @param source A sequence of xtd::int64 values to calculate the average of.
262270 // / @return The average of the sequence of values.
263271 // / @exception xtd::invalid_operation_exception `source` contains no elements.
264- [[nodiscard]] static auto average (const ienumerable<xtd::int64>& source) -> double;
265-
272+ template <xtd::forward_iterable source_t >
273+ requires xtd::signed_integer_64<typename xtd::raw_type<source_t >::value_type>
274+ [[nodiscard]] static auto average (source_t && source) -> double;
275+
266276 // / @brief Computes the average of a sequence of optional xtd::decimal values.
267277 // / @param source A sequence of optional xtd::decimal values to calculate the average of.
268278 // / @return The average of the sequence of values, or xtd::nullopt if the source sequence is empty or contains only values that are xtd::nullopt.
0 commit comments