Hi Ken,

> ...
> looks nice.  I avoided template member functions out of fear of old
> compilers.  Such concerns are very important to the FLTK team.

Eight years ago, absolutely agree.  Five years ago, you are right, it was still 
a concern.  Today, personally I don't think so.  I would be astounded if there 
was anyone out there using a C++ compiler that couldn't handle the simple 
template code I gave as an example.

I'm aware one can overcome the present API with external template code to plug 
into a functor.  The reason I started this thread was because I feel nowadays 
template code is widely supported and am asking the question "can this part of 
the API be improved (i.e made type safe) now that templates are widely 
supported".  If you think the answer is yes then what is the best API one can 
come up with w.r.t callbacks?


> Mike wrote:
> > True, templatizing the entire Widget class would cause code bloat
> > which is why one would be mad to do it.  It is possible to implement
> > the template m/f I suggested without templatizing the whole widget
> > class.  For example:
> >
>
> I implemented a replacement for the fltk callback mechanism a few years
> ago called fl_connect:
>
>      http://cscdev.lvc.edu/fl_connect
>
> I haven't maintained that website in awhile (apologies), but the code
> ports without problems to fltk-1.1.x (I've patched v1.1.8, for instance).
>
> My solution uses templates, but doesn't templatize Widget;  a template
> function creates the static forwarding functions for you, so user code
> looks nice.  I avoided template member functions out of fear of old
> compilers.  Such concerns are very important to the FLTK team.
>
> I did some tests back in the day, and found essentially no performance
> penalty and no code bloat (the template mechanism essentially writes the
> same code you would have to write, anyway, if you were to use member
> function callbacks).  The use of templates here carries no downside.
>
> I will try to find time to port my solution to 1.3, but it will be
> awhile (2 months?) before that can happen.
>
> Ken
> --
> Ken Yarnall
> Dept. of Mathematical Sciences               Lebanon Valley College
> Assoc. Professor of Math and CS       (717)867-6085 yarn...@lvc.edu
>

_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to