[Kde-pim] Need to rename a kcal class for msvc compile
David Faure
faure at kde.org
Thu Jan 11 21:33:55 GMT 2007
The testcase below doesn't compile with msvc, because "Observer" inside Calendar methods
is interpreted as the base class (IncidenceBase::Observer) instead of being interpreted as
the nested Observer class. I don't see an easy workaround that would make msvc eat this,
so I would like to request permission to rename one of the two observer classes.
For instance, Calendar::Observer could become Calendar::CalendarObserver. Any objections?
class IncidenceBase {
public:
class Observer {
public:
void incidenceUpdated() {}
};
};
class Calendar : public IncidenceBase::Observer {
public:
class Observer {
public:
virtual ~Observer() {}
virtual void modified() {}
};
void registerObserver( Observer * ) {}
};
class ResourceCached : public Calendar::Observer
{
public:
ResourceCached() {}
void enableChangeNotification();
private:
Calendar mCalendar;
};
void ResourceCached::enableChangeNotification()
{
#ifndef __GNUC__
mCalendar.Observer::incidenceUpdated(); // compiles with msvc!
// This proves that msvc really thinks that Calendar::Observer means
// Calendar::IncidenceBase::Observer instead of the nested class
#endif
// The line below breaks, because msvc parsed registerObserver(Observer*)
// as registerObserver(IncidenceBase::Observer*).
mCalendar.registerObserver( this );
}
int main()
{
ResourceCached rc;
rc.enableChangeNotification();
return 42;
}
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
More information about the kde-pim
mailing list