#ifndef COMPRESSION_HPP #define COMPRESSION_HPP #include #include typedef unsigned long buffer_t; /** * The compressed size metafunction returns the bit-width of a particular data * type and determines how many bits can be used to encode the data structure. * Note that this is generally not deducible from the data type and must be * specified explicitly through specializations of this class. By default, we * assume that types are not compressible. */ template struct compression_traits { typedef std::false_type is_compressable; typedef std::integral_constant compressed_size; }; // A helper metafunction that indicates that T is compressable over the // specified number of bits. template struct compressable { typedef std::true_type is_compressable; typedef std::integral_constant compressed_size; }; // Metafunctions /** Returns true if the type T is compressed. */ template struct is_compressable : compression_traits::is_compressable { }; /** Returns the numbef of bits into which T can be compressed. */ template struct compressed_size : compression_traits::compressed_size { }; // Compression masks /** * The compression mask metafunction returns an integer expression that can be * shifted and applied to an element in order to extract its value. */ template struct compression_mask : std::integral_constant { }; // Specializations template <> struct compression_traits : compressable { }; #endif