Commit 17f04f0a by Nicolas Capens Committed by Nicolas Capens

Work around Visual Studio static constexpr bug.

Visual Studio doesn't recognize the use of a class member in a static constexpr unless prefixed with the class name. BUG=swiftshader:7 Change-Id: I4ffbaa6fc1a43a7294ecdaf426bd7fc2aab5e469 Reviewed-on: https://chromium-review.googlesource.com/380195Reviewed-by: 's avatarJim Stichnoth <stichnot@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 3db8f7a2
......@@ -186,19 +186,19 @@ private:
ElementType Bits[BitsElements];
// MaxBits is defined here because it needs Bits to be defined.
static constexpr SizeT MaxBits = sizeof(Bits) * CHAR_BIT;
static_assert(sizeof(Bits) == 16, "Bits must be 16 bytes wide.");
static constexpr SizeT MaxBits = sizeof(SmallBitVector::Bits) * CHAR_BIT;
static_assert(sizeof(SmallBitVector::Bits) == 16,
"Bits must be 16 bytes wide.");
SizeT Size = 0;
template <SizeT Pos>
typename std::enable_if<Pos == sizeof(Bits) / sizeof(Bits[0]), int>::type
find_first() const {
typename std::enable_if<Pos == BitsElements, int>::type find_first() const {
return -1;
}
template <SizeT Pos>
typename std::enable_if <
Pos<sizeof(Bits) / sizeof(Bits[0]), int>::type find_first() const {
Pos<BitsElements, int>::type find_first() const {
if (Bits[Pos] != 0) {
return NumBitsPerPos * Pos + llvm::countTrailingZeros(Bits[Pos]);
}
......@@ -206,14 +206,14 @@ private:
}
template <SizeT Pos>
typename std::enable_if<Pos == sizeof(Bits) / sizeof(Bits[0]), int>::type
typename std::enable_if<Pos == BitsElements, int>::type
find_next(unsigned) const {
return -1;
}
template <SizeT Pos>
typename std::enable_if < Pos<sizeof(Bits) / sizeof(Bits[0]), int>::type
find_next(unsigned Prev) const {
typename std::enable_if <
Pos<BitsElements, int>::type find_next(unsigned Prev) const {
if (Prev + 1 < (Pos + 1) * NumBitsPerPos) {
const ElementType Mask =
(ElementType(1) << ((Prev + 1) - Pos * NumBitsPerPos)) - 1;
......@@ -227,12 +227,10 @@ private:
}
template <SizeT Pos>
typename std::enable_if<Pos == sizeof(Bits) / sizeof(Bits[0]), void>::type
invert() {}
typename std::enable_if<Pos == BitsElements, void>::type invert() {}
template <SizeT Pos>
typename std::enable_if <
Pos<sizeof(Bits) / sizeof(Bits[0]), void>::type invert() {
typename std::enable_if < Pos<BitsElements, void>::type invert() {
if (size() < Pos * NumBitsPerPos) {
Bits[Pos] = 0;
} else if ((Pos + 1) * NumBitsPerPos < size()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment