Fix clang 8 & libc++ build errors
Replace operators for implicit type conversion by explicit data() method to access implementation pointer and subscript operator to access element by index just like in std::vector. src/osgPlugins/tga/ReaderWriterTGA.cpp:455:22: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (colormap == NULL) ~~~~~~~~ ^ ~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:525:16: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (buffer == NULL || linebuf == NULL) ~~~~~~ ^ ~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:525:35: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (buffer == NULL || linebuf == NULL) ~~~~~~~ ^ ~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:548:30: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (formattedMap == NULL) ~~~~~~~~~~~~ ^ ~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:574:40: error: use of overloaded operator '[]' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = linebuf[x]; ~~~~~~~^~ src/osgPlugins/tga/ReaderWriterTGA.cpp:577:50: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = getInt16(linebuf + x * 2); ~~~~~~~ ^ ~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:580:50: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = getInt24(linebuf + x * 3); ~~~~~~~ ^ ~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:583:50: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = getInt32(linebuf + x * 4); ~~~~~~~ ^ ~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:592:72: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') (dest + adjustedX * format)[i] = (formattedMap + index * format)[i]; ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:626:30: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (formattedMap == NULL) ~~~~~~~~~~~~ ^ ~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:642:21: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (buf == NULL) ~~~ ^ ~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:664:44: error: use of overloaded operator '[]' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = linebuf[x]; ~~~~~~~^~ src/osgPlugins/tga/ReaderWriterTGA.cpp:667:54: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = getInt16(linebuf + x * 2); ~~~~~~~ ^ ~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:670:54: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = getInt24(linebuf + x * 3); ~~~~~~~ ^ ~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:673:54: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') index = getInt32(linebuf + x * 4); ~~~~~~~ ^ ~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:688:76: error: use of overloaded operator '+' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'int') (dest + adjustedX * format)[i] = (formattedMap + index * format)[i]; ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ src/osgPlugins/tga/ReaderWriterTGA.cpp:708:21: error: use of overloaded operator '==' is ambiguous (with operand types 'SafeArray<unsigned char>' and 'long') if (buf == NULL) ~~~ ^ ~~~~ 17 errors generated.
This commit is contained in:
parent
ddea94b41c
commit
c0ea4c6310
@ -322,10 +322,13 @@ struct SafeArray
|
||||
impl = new T[size];
|
||||
}
|
||||
|
||||
operator T*() { return impl; }
|
||||
const T& operator[](std::size_t i) const { return impl[i]; }
|
||||
|
||||
template<typename U>
|
||||
operator U() { return (U)impl; }
|
||||
T& operator[](std::size_t i) { return impl[i]; }
|
||||
|
||||
const T* data() const { return impl; }
|
||||
|
||||
T* data() { return impl; }
|
||||
|
||||
private:
|
||||
T* impl;
|
||||
@ -452,12 +455,12 @@ int *numComponents_ret)
|
||||
colormapLen = getInt16(&header[5]);
|
||||
colormapDepth = (header[7] + 7) >> 3;
|
||||
colormap.reinitialise(colormapLen*colormapDepth);
|
||||
if (colormap == NULL)
|
||||
if (colormap.data() == NULL)
|
||||
{
|
||||
tgaerror = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
fin.read((char*)colormap, colormapLen*colormapDepth);
|
||||
fin.read(reinterpret_cast<char*>(colormap.data()), colormapLen*colormapDepth);
|
||||
|
||||
if (colormapDepth == 2) /* 16 bits */
|
||||
{
|
||||
@ -518,11 +521,11 @@ int *numComponents_ret)
|
||||
rleRemaining = 0;
|
||||
rleEntrySize = depth;
|
||||
SafeArray<unsigned char> buffer(width*height*format);
|
||||
dest = buffer;
|
||||
dest = buffer.data();
|
||||
bpr = format * width;
|
||||
SafeArray<unsigned char> linebuf(width * depth);
|
||||
|
||||
if (buffer == NULL || linebuf == NULL)
|
||||
if (buffer.data() == NULL || linebuf.data() == NULL)
|
||||
{
|
||||
tgaerror = ERR_MEM;
|
||||
return NULL;
|
||||
@ -545,20 +548,20 @@ int *numComponents_ret)
|
||||
return NULL;
|
||||
}
|
||||
SafeArray<unsigned char> formattedMap(colormapLen * format);
|
||||
if (formattedMap == NULL)
|
||||
if (formattedMap.data() == NULL)
|
||||
{
|
||||
tgaerror = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < colormapLen; i++)
|
||||
{
|
||||
convert_data(colormap, formattedMap, i, colormapDepth, format);
|
||||
convert_data(colormap.data(), formattedMap.data(), i, colormapDepth, format);
|
||||
}
|
||||
|
||||
int x, y;
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
fin.read((char*)linebuf, width*depth);
|
||||
fin.read(reinterpret_cast<char*>(linebuf.data()), width*depth);
|
||||
if (fin.gcount() != (std::streamsize) (width*depth))
|
||||
{
|
||||
tgaerror = ERR_READ;
|
||||
@ -574,13 +577,13 @@ int *numComponents_ret)
|
||||
index = linebuf[x];
|
||||
break;
|
||||
case 2:
|
||||
index = getInt16(linebuf + x * 2);
|
||||
index = getInt16(linebuf.data() + x * 2);
|
||||
break;
|
||||
case 3:
|
||||
index = getInt24(linebuf + x * 3);
|
||||
index = getInt24(linebuf.data() + x * 3);
|
||||
break;
|
||||
case 4:
|
||||
index = getInt32(linebuf + x * 4);
|
||||
index = getInt32(linebuf.data() + x * 4);
|
||||
break;
|
||||
default:
|
||||
tgaerror = ERR_UNSUPPORTED;
|
||||
@ -589,7 +592,7 @@ int *numComponents_ret)
|
||||
|
||||
int adjustedX = bLeftToRight ? x : (width - 1) - x;
|
||||
for (int i = 0; i < format; i++)
|
||||
(dest + adjustedX * format)[i] = (formattedMap + index * format)[i];
|
||||
(dest + adjustedX * format)[i] = formattedMap[index * format + i];
|
||||
}
|
||||
dest += lineoffset;
|
||||
}
|
||||
@ -601,7 +604,7 @@ int *numComponents_ret)
|
||||
int x, y;
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
fin.read((char*)linebuf,width*depth);
|
||||
fin.read(reinterpret_cast<char*>(linebuf.data()), width*depth);
|
||||
if (fin.gcount() != (std::streamsize) (width*depth))
|
||||
{
|
||||
tgaerror = ERR_READ;
|
||||
@ -609,7 +612,7 @@ int *numComponents_ret)
|
||||
}
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
convert_data(linebuf, dest, bLeftToRight ? x : (width-1) - x, depth, format);
|
||||
convert_data(linebuf.data(), dest, bLeftToRight ? x : (width-1) - x, depth, format);
|
||||
}
|
||||
dest += lineoffset;
|
||||
}
|
||||
@ -623,14 +626,14 @@ int *numComponents_ret)
|
||||
return NULL;
|
||||
}
|
||||
SafeArray<unsigned char> formattedMap(colormapLen * format);
|
||||
if (formattedMap == NULL)
|
||||
if (formattedMap.data() == NULL)
|
||||
{
|
||||
tgaerror = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < colormapLen; i++)
|
||||
{
|
||||
convert_data(colormap, formattedMap, i, colormapDepth, format);
|
||||
convert_data(colormap.data(), formattedMap.data(), i, colormapDepth, format);
|
||||
}
|
||||
|
||||
int size, x, y;
|
||||
@ -639,19 +642,19 @@ int *numComponents_ret)
|
||||
size = (int)(endOfImage - pos);
|
||||
|
||||
SafeArray<unsigned char> buf(size);
|
||||
if (buf == NULL)
|
||||
if (buf.data() == NULL)
|
||||
{
|
||||
tgaerror = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
unsigned char* src = buf;
|
||||
unsigned char* src = buf.data();
|
||||
|
||||
fin.read((char*)buf, size);
|
||||
fin.read(reinterpret_cast<char*>(buf.data()), size);
|
||||
if (fin.gcount() == (std::streamsize)size)
|
||||
{
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
rle_decode(&src, linebuf, width*depth, &rleRemaining,
|
||||
rle_decode(&src, linebuf.data(), width*depth, &rleRemaining,
|
||||
&rleIsCompressed, rleCurrent, rleEntrySize);
|
||||
assert(src <= buf + size);
|
||||
|
||||
@ -664,13 +667,13 @@ int *numComponents_ret)
|
||||
index = linebuf[x];
|
||||
break;
|
||||
case 2:
|
||||
index = getInt16(linebuf + x * 2);
|
||||
index = getInt16(linebuf.data() + x * 2);
|
||||
break;
|
||||
case 3:
|
||||
index = getInt24(linebuf + x * 3);
|
||||
index = getInt24(linebuf.data() + x * 3);
|
||||
break;
|
||||
case 4:
|
||||
index = getInt32(linebuf + x * 4);
|
||||
index = getInt32(linebuf.data() + x * 4);
|
||||
break;
|
||||
default:
|
||||
tgaerror = ERR_UNSUPPORTED;
|
||||
@ -685,7 +688,7 @@ int *numComponents_ret)
|
||||
|
||||
int adjustedX = bLeftToRight ? x : (width - 1) - x;
|
||||
for (int i = 0; i < format; i++)
|
||||
(dest + adjustedX * format)[i] = (formattedMap + index * format)[i];
|
||||
(dest + adjustedX * format)[i] = formattedMap[index * format + i];
|
||||
}
|
||||
dest += lineoffset;
|
||||
}
|
||||
@ -705,24 +708,24 @@ int *numComponents_ret)
|
||||
|
||||
size = (int)(endOfImage - pos);
|
||||
SafeArray<unsigned char> buf(size);
|
||||
if (buf == NULL)
|
||||
if (buf.data() == NULL)
|
||||
{
|
||||
tgaerror = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
unsigned char* src = buf;
|
||||
unsigned char* src = buf.data();
|
||||
|
||||
fin.read((char*)buf,size);
|
||||
fin.read(reinterpret_cast<char*>(buf.data()), size);
|
||||
if (fin.gcount() == (std::streamsize) size)
|
||||
{
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
rle_decode(&src, linebuf, width*depth, &rleRemaining,
|
||||
rle_decode(&src, linebuf.data(), width*depth, &rleRemaining,
|
||||
&rleIsCompressed, rleCurrent, rleEntrySize);
|
||||
assert(src <= buf + size);
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
convert_data(linebuf, dest, bLeftToRight ? x : (width-1) - x, depth, format);
|
||||
convert_data(linebuf.data(), dest, bLeftToRight ? x : (width-1) - x, depth, format);
|
||||
}
|
||||
dest += lineoffset;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user