|
Ublas : |
Subject: [ublas] Is there a special reason to use inline before template functions?
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2008-12-07 18:48:13
Hi,
in boost, many template functions (but not all) use inline.
(Example from boost/accumulators/framework/accumulator_set.hpp that uses inline:
template<typename Args>
inline accumulator_visitor<Args> const make_accumulator_visitor(Args const &args)
{
return accumulator_visitor<Args>(args);
}
Example from boost/algorithm/minmax.hpp hat doesn't use inline:
template <typename T>
tuple< T const&, T const& >
minmax(T const& a, T const& b) {
return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
}
)
Is there a special reason why inline is used for template functions? I would expect that current compilers know better when inlining a function provides a benefit than the programmer. So I guess there is a better reason for using the inline keyword before template function than just speculative performance optimization, but I can't figure it out. Can anybody help me?
Most libs only prepend inline before template functions, but ublas prepends nearly every member function with the macro "BOOST_UBLAS_INLINE", which expands to "inline". Is there a reason why ublas uses this macro?
Regards,
Thomas