Browse Source

Math: functions were not inline by mistake.

It's inline for all others of similar size, so why not this.
pull/286/merge
Vladimír Vondruš 8 years ago
parent
commit
edff639204
  1. 38
      src/Magnum/Math/Functions.h

38
src/Magnum/Math/Functions.h

@ -91,7 +91,7 @@ UnsignedInt MAGNUM_EXPORT log2(UnsignedInt number);
Returns natural (base @f$ e @f$) logarithm of given number.
@see @ref Constants::e(), @ref log(UnsignedInt, UnsignedInt), @ref log2()
*/
template<class T> T log(T number) { return std::log(number); }
template<class T> inline T log(T number) { return std::log(number); }
/**
@brief Natural exponential
@ -99,7 +99,7 @@ template<class T> T log(T number) { return std::log(number); }
Returns @f$ e^x @f$.
@see @ref Constants::e(), @ref pow(T, T)
*/
template<class T> T exp(T exponent) { return std::exp(exponent); }
template<class T> inline T exp(T exponent) { return std::exp(exponent); }
/**
@brief Integer division with remainder
@ -118,7 +118,7 @@ Int quotient = 57/6;
Int remainder = 57%6;
@endcode
*/
template<class Integral> std::pair<Integral, Integral> div(Integral x, Integral y) {
template<class Integral> inline std::pair<Integral, Integral> div(Integral x, Integral y) {
static_assert(std::is_integral<Integral>{}, "Math::div(): not an integral type");
const auto result = std::div(x, y);
return {result.quot, result.rem};
@ -220,7 +220,7 @@ template<UnsignedInt exponent, class T> constexpr T pow(T base);
template<UnsignedInt exponent, class T> constexpr typename std::enable_if<std::is_arithmetic<T>::value, T>::type pow(T base) {
return Implementation::Pow<exponent>::pow(base);
}
template<UnsignedInt exponent, std::size_t size, class T> Vector<size, T> pow(const Vector<size, T>& base) {
template<UnsignedInt exponent, std::size_t size, class T> inline Vector<size, T> pow(const Vector<size, T>& base) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = Implementation::Pow<exponent>::pow(base[i]);
@ -237,7 +237,7 @@ Returns power of @p base to the @p exponent.
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> T pow(T base, T exponent);
#else
template<class T> typename std::enable_if<std::is_arithmetic<T>::value, T>::type pow(T base, T exponent) {
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type pow(T base, T exponent) {
return std::pow(base, exponent);
}
template<std::size_t size, class T> inline Vector<size, T> pow(const Vector<size, T>& base, T exponent) {
@ -281,7 +281,7 @@ template<std::size_t size, class T> inline Vector<size, T> min(const Vector<size
If the range is empty, returns default-constructed value.
*/
template<class T> T min(Corrade::Containers::ArrayView<const T> range) {
template<class T> inline T min(Corrade::Containers::ArrayView<const T> range) {
if(range.empty()) return {};
T out(range[0]);
@ -321,7 +321,7 @@ template<std::size_t size, class T> Vector<size, T> max(const Vector<size, T>& v
#endif
/** @overload */
template<std::size_t size, class T> Vector<size, T> max(const Vector<size, T>& value, T max) {
template<std::size_t size, class T> inline Vector<size, T> max(const Vector<size, T>& value, T max) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = std::max(value[i], max);
@ -333,7 +333,7 @@ template<std::size_t size, class T> Vector<size, T> max(const Vector<size, T>& v
If the range is empty, returns default-constructed value.
*/
template<class T> T max(Corrade::Containers::ArrayView<const T> range) {
template<class T> inline T max(Corrade::Containers::ArrayView<const T> range) {
if(range.empty()) return {};
T out(range[0]);
@ -364,7 +364,7 @@ template<class T> inline std::pair<T, T> minmax(const T& a, const T& b);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, std::pair<T, T>>::type minmax(T a, T b) {
return a < b ? std::make_pair(a, b) : std::make_pair(b, a);
}
template<std::size_t size, class T> std::pair<Vector<size, T>, Vector<size, T>> minmax(const Vector<size, T>& a, const Vector<size, T>& b) {
template<std::size_t size, class T> inline std::pair<Vector<size, T>, Vector<size, T>> minmax(const Vector<size, T>& a, const Vector<size, T>& b) {
using std::swap;
std::pair<Vector<size, T>, Vector<size, T>> out{a, b};
for(std::size_t i = 0; i != size; ++i)
@ -392,7 +392,7 @@ namespace Implementation {
If the range is empty, returns default-constructed values.
@see @ref Range::Range(const std::pair<VectorType, VectorType>&)
*/
template<class T> std::pair<T, T> minmax(Corrade::Containers::ArrayView<const T> range) {
template<class T> inline std::pair<T, T> minmax(Corrade::Containers::ArrayView<const T> range) {
if(range.empty()) return {};
T min{range[0]}, max{range[0]};
@ -431,7 +431,7 @@ template<class T, class U> inline T clamp(const T& value, const T& min, const T&
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type clamp(T value, T min, T max) {
return std::min(std::max(value, min), max);
}
template<std::size_t size, class T> Vector<size, T> clamp(const Vector<size, T>& value, const Vector<size, T>& min, const Vector<size, T>& max) {
template<std::size_t size, class T> inline Vector<size, T> clamp(const Vector<size, T>& value, const Vector<size, T>& min, const Vector<size, T>& max) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = clamp(value[i], min[i], max[i]);
@ -440,7 +440,7 @@ template<std::size_t size, class T> Vector<size, T> clamp(const Vector<size, T>&
#endif
/** @overload */
template<std::size_t size, class T> Vector<size, T> clamp(const Vector<size, T>& value, T min, T max) {
template<std::size_t size, class T> inline Vector<size, T> clamp(const Vector<size, T>& value, T min, T max) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = clamp(value[i], min, max);
@ -460,7 +460,7 @@ template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T
if(scalar < T(0)) return T(-1);
return T(0);
}
template<std::size_t size, class T> Vector<size, T> sign(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> sign(const Vector<size, T>& a) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = sign(a[i]);
@ -475,7 +475,7 @@ template<class T> inline T abs(const T& a);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type abs(T a) {
return std::abs(a);
}
template<std::size_t size, class T> Vector<size, T> abs(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> abs(const Vector<size, T>& a) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = std::abs(a[i]);
@ -490,7 +490,7 @@ template<class T> inline T floor(const T& a);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type floor(T a) {
return std::floor(a);
}
template<std::size_t size, class T> Vector<size, T> floor(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> floor(const Vector<size, T>& a) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = std::floor(a[i]);
@ -505,7 +505,7 @@ template<class T> inline T round(const T& a);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type round(T a) {
return std::round(a);
}
template<std::size_t size, class T> Vector<size, T> round(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> round(const Vector<size, T>& a) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = std::round(a[i]);
@ -520,7 +520,7 @@ template<class T> inline T ceil(const T& a);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type ceil(T a) {
return std::ceil(a);
}
template<std::size_t size, class T> Vector<size, T> ceil(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> ceil(const Vector<size, T>& a) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = std::ceil(a[i]);
@ -539,7 +539,7 @@ template<class T> inline T sqrt(const T& a);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sqrt(T a) {
return T(std::sqrt(a));
}
template<std::size_t size, class T> Vector<size, T> sqrt(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> sqrt(const Vector<size, T>& a) {
Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i)
out[i] = T(std::sqrt(a[i]));
@ -559,7 +559,7 @@ template<class T> inline T sqrtInverted(const T& a);
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type sqrtInverted(T a) {
return T(1)/std::sqrt(a);
}
template<std::size_t size, class T> Vector<size, T> sqrtInverted(const Vector<size, T>& a) {
template<std::size_t size, class T> inline Vector<size, T> sqrtInverted(const Vector<size, T>& a) {
return Vector<size, T>(T(1))/sqrt(a);
}
#endif

Loading…
Cancel
Save