On Tuesday February 21 2012, André Somers wrote: > Op 21-2-2012 9:35, Thiago Macieira schreef: > > On terça-feira, 21 de fevereiro de 2012 08.24.52, Samuel Rødal wrote: > >> Also, I guess we'll want convenience functions "QRectD QRectF::toRectD() > >> const" etc. Can that be done with the typedefs proposed above, or does > >> it require having "QRectD QRectD::toRectD() const" as well? > > > > With some template magic it can be done. > > > > If you write: > > template<class t> class QBasicRect; > > typedef QBasicRect<float> QRectF; > > typedef QBasicRect<double> QRectD; > > > > Then you can't specialise QBasicRect<float or double> anymore. You can > > only use the default expansion or partial specialisations that are yet to > > be written. That means it's easier to add an "constexpr inline QRectD > > toRectD() const;" to all classes than to just the float and integer ones. > > > > But someone really motivated can add more magic using QEnableIf. > > Just wondering: while I think using templates for these classes is a > good idea in principle, will using such template magic as you are > suggesting here hurt compilation times, both of Qt itself and Qt > applications using these classes?
One would disallow compilers to instantiate the template with C++11 extern templates (this would be a good idea for all templates, esp. those with arguments constrained to just a few potential types). All other compilers: who cares? :) Thanks, Marc -- Marc Mutz <marc.m...@kdab.com> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-Independent Software Solutions _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development