I've seen various incarnations of my question answered/replied too but I'm still having a hard time figuring out how to omit functions my compiler states are ambiguous.
I have a class that is designed to handle streams of data. I have overloaded = and += operators so that the stream class can consume data of other types by transposing it into the template type T.
template<typename T>
class TStream
{
private:
typedef TBuffer<T> stream_buffer;
stream_buffer mStream;
public:
TStream();
TStream(const TStream &rhs);
TStream::~TStream();
unsigned int Size() const;
unsigned int ByteStreamLength() const;
void Clear();
// some methods omitted for brevity
const T&operator[](unsigned int idx);
const T*operator[](unsigned int idx) const;
TStream<T> &operator=(const TStream &rhs);
TStream<T> &operator=(T const);
TStream<T> &operator=(unsigned char);
TStream<T> &operator=(bool);
TStream<T> &operator=(double);
// rest omitted for brevity
};
Doing this
TStream<unsigned char> ByteStream
causes ambiguity with
operator=(unsigned char).
I basically want operator=(unsigned char) to be omitted if T = unsigned char.
This article appears to give a way to do it: http://www.drdobbs.com/function-overloading-based-on-arbitrary/184401659
But having a hard time following it because I don't want to alter my return types.
I typically use TStream like this:
TStream<unsigned byte> ByteStream;
ByteStream+= int
ByteStream+= char
... etc, where I overload the += in the same way. I deduce the size coming in and convert it to the T. I do this to avoid passing a void * and a length argument for the simple POD cases.