B
bob
Hi,
I have a shi*t load of warnings that are present in a legacy app. We
need to remove them.
We have a template class that is used extensively throughout the code.
The class looks something like this;
template <class T>
class TtkPtr : public TtkObject
{
protected:
TtkPtr () {ptr = NULL;};
public:
virtual ~TtkPtr() {};
//------------- Accessors ------------------
operator const T* () const {return ptr;};
operator T* () {return ptr;};
// snip snip etc. ....
}
Now during compilation there are various (lots and lots) of warning
complaining about something like;
Warning W8037 .\blah.cpp 3411: Non-const function TtkPtr<AnalyserBlah>:
perator AnalyserBlah*() called for const object in function ... blah
blah blah.
Now I would like to ask the following;
If I added the following operator;
operator T* () const {return ptr;};
to the above template class, I will see my warnings go away (at least
I think I will I haven't compiled anything in yet).
Am I playing with fire doing that? If yes, any suggestions how to
proceed?
thanks much and have a nice day.
GrahamO
I have a shi*t load of warnings that are present in a legacy app. We
need to remove them.
We have a template class that is used extensively throughout the code.
The class looks something like this;
template <class T>
class TtkPtr : public TtkObject
{
protected:
TtkPtr () {ptr = NULL;};
public:
virtual ~TtkPtr() {};
//------------- Accessors ------------------
operator const T* () const {return ptr;};
operator T* () {return ptr;};
// snip snip etc. ....
}
Now during compilation there are various (lots and lots) of warning
complaining about something like;
Warning W8037 .\blah.cpp 3411: Non-const function TtkPtr<AnalyserBlah>:
blah blah.
Now I would like to ask the following;
If I added the following operator;
operator T* () const {return ptr;};
to the above template class, I will see my warnings go away (at least
I think I will I haven't compiled anything in yet).
Am I playing with fire doing that? If yes, any suggestions how to
proceed?
thanks much and have a nice day.
GrahamO