From 28ad79c97ab273d5077847cc81ca969c63474219 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 1 Dec 2013 19:29:55 +0100 Subject: pcm/Traits: add typedef long_type --- src/pcm/Traits.hxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/pcm/Traits.hxx b/src/pcm/Traits.hxx index b102b41ab..58a61c9c5 100644 --- a/src/pcm/Traits.hxx +++ b/src/pcm/Traits.hxx @@ -50,6 +50,13 @@ struct SampleTraits { */ typedef const value_type *const_pointer_type; + /** + * A "long" type that is large and accurate enough for + * arithmetic without risking an (integer) overflow or + * (floating point) precision loss. + */ + typedef int long_type; + /** * The size of one sample in bytes. */ @@ -68,6 +75,8 @@ struct SampleTraits { typedef value_type *pointer_type; typedef const value_type *const_pointer_type; + typedef int long_type; + static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr unsigned BITS = sizeof(value_type) * 8; }; @@ -78,6 +87,8 @@ struct SampleTraits { typedef value_type *pointer_type; typedef const value_type *const_pointer_type; + typedef int64_t long_type; + static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr unsigned BITS = sizeof(value_type) * 8; }; @@ -88,6 +99,8 @@ struct SampleTraits { typedef value_type *pointer_type; typedef const value_type *const_pointer_type; + typedef int long_type; + static constexpr size_t SAMPLE_SIZE = sizeof(value_type); static constexpr unsigned BITS = 24; }; -- cgit v1.2.3