I'm reading Alex Graves's rnnlib.
In his codes there are many static function templates which are not class member methods but defined as static, while some are not.(see below)
Some code snipplets of Helpers.hpp:
...
// static
template <class R> static void sort(R& r)
{
sort(boost::begin(r), boost::end(r));
}
// static
template <class R> static void reverse_sort(R& r)
{
sort(boost::rbegin(r), boost::rend(r));
}
// non static
template <class R> pair<typename range_value<R>::type, typename range_value<R>::type> minmax(const R& r)
{
pair<typename range_const_iterator<R>::type, typename range_const_iterator<R>::type> p = minmax_element(boost::begin(r), boost::end(r));
return make_pair(*p.first, *p.second);
}
// static
template <class R> static void bound_range (R& r, const typename boost::range_value<R>::type& minVal, const typename boost::range_value<R>::type& maxVal)
{
for (typename range_iterator<R>::type it = boost::begin(r); it != boost::end(r); ++it)
{
*it = bound(*it, minVal, maxVal);
}
}
...
Why are some of these global function templates defined as static while some are not?