pcm/Clamp: convert to `constexpr`

This commit is contained in:
Max Kellermann 2018-10-30 00:06:48 +01:00
parent bb5918932b
commit 804ccddf7e
3 changed files with 3 additions and 5 deletions

View File

@ -34,8 +34,7 @@ template<SampleFormat F> struct SampleTraits;
* and caps it if necessary.
*/
template<SampleFormat F, class Traits=SampleTraits<F>>
gcc_const
static inline typename Traits::value_type
constexpr typename Traits::value_type
PcmClamp(typename Traits::long_type x) noexcept
{
typedef typename Traits::value_type T;

View File

@ -37,8 +37,7 @@ struct FloatToIntegerSampleConvert {
static constexpr SV factor = uintmax_t(1) << (DstTraits::BITS - 1);
static_assert(factor > 0, "Wrong factor");
gcc_const
static DV Convert(SV src) noexcept {
static constexpr DV Convert(SV src) noexcept {
return PcmClamp<F, Traits>(SL(src * factor));
}
};

View File

@ -134,7 +134,7 @@ pcm_add_vol(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
}
template<SampleFormat F, class Traits=SampleTraits<F>>
static typename Traits::value_type
static constexpr typename Traits::value_type
PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b) noexcept
{
typename Traits::sum_type a(_a), b(_b);