For this template declaration:
template <class Iterator>
typename std::iterator_traits<Iterator>::value_type Mean(Iterator begin, Iterator end);
I would like to simplify the value_type typename with a "using declaration" or typedef. So that it is a easier to read the return type. Is there a way to do this in the declaration?
>Solution :
You can add an template alias like
template <typename Iterator>
using iterator_value_type_t = typename std::iterator_traits<Iterator>::value_type;
and then you can use that with your function like
template <class Iterator>
iterator_value_type_t<Iterator> Mean(Iterator begin, Iterator end);
If you want to allow specifying a custom return type then you can move the return type into the template parameter list like
template <class Iterator,
class ReturnType = typename std::iterator_traits<Iterator>::value_type>
ReturnType Mean(Iterator begin, Iterator end);