aboutsummaryrefslogtreecommitdiff
path: root/src/decoder/integer_sequence_codec.cc
diff options
context:
space:
mode:
authorGravatar Erwin Jansen <jansene@google.com>2018-11-21 16:09:40 -0800
committerGravatar Erwin Jansen <jansene@google.com>2018-11-27 10:24:19 -0800
commitbaf0508027872f50198e838fe1148b73a9b11b1f (patch)
treec1c350b5ec2b39c1c036e576968a003c84056028 /src/decoder/integer_sequence_codec.cc
parent16661ba8c0103c2571e84a59a107c9e41dbe60dc (diff)
CMake support to enable compilation under Visual Studio
- Add support for cmake - Template fix to enable compilation with visual studio. - Exclusion of static type tests under visual studio - Fix unit tests due to declaration issues Note we do not build the fuzzing target. Test: All unit tests green on VS2017, MacOs, Linux Change-Id: Ie8437f61d187fff03279c99fde0ff565e8f39b50
Diffstat (limited to 'src/decoder/integer_sequence_codec.cc')
-rw-r--r--src/decoder/integer_sequence_codec.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/decoder/integer_sequence_codec.cc b/src/decoder/integer_sequence_codec.cc
index 83c0359..c2cd511 100644
--- a/src/decoder/integer_sequence_codec.cc
+++ b/src/decoder/integer_sequence_codec.cc
@@ -193,13 +193,20 @@ inline constexpr bool IsPow2(T x) { return (x & (x - 1)) == 0; }
const int kInterleavedQuintBits[3] = { 3, 2, 2 };
const int kInterleavedTritBits[5] = { 2, 2, 1, 2, 1 };
+// Some template meta programming to get around the fact that MSVC
+// will not allow (ValRange == 5) ? 3 : 5 as a template parameter
+template<int ValRange>
+struct DecodeBlockSize {
+ enum { value = (ValRange == 5 ? 3 : 5) };
+};
+
// Decodes either a trit or quint block using the BISE (Bounded Integer Sequence
// Encoding) defined in Section C.2.12 of the ASTC specification. ValRange is
// expected to be either 3 or 5 depending on whether or not we're encoding trits
// or quints respectively. In other words, it is the remaining factor in whether
// the passed blocks contain encoded values of the form 3*2^k or 5*2^k.
template<int ValRange>
-std::array<int, /* kNumVals = */ (ValRange == 5) ? 3 : 5> DecodeISEBlock(
+std::array<int, /* kNumVals = */ DecodeBlockSize<ValRange>::value> DecodeISEBlock(
uint64_t block_bits, int num_bits) {
static_assert(ValRange == 3 || ValRange == 5,
"We only know about trits and quints");