[LC++]STL Iterators and integers

Dan hursh hursh at sparc.isl.net
Fri Aug 10 01:30:06 UTC 2001


On Thu, 9 Aug 2001, Grzegorz Mazur wrote:
<snip>
> And I can't really understand what's the reason behind a container with
> std::vector interface, but with all member functions virtual. Would you
> care to give an example?

    Well, I can't justify everything he's trying to do, but I know I've
been in situation where I have data, say a mathimatic vector, and I want
to use it with two libraries that can agree on a representation.  Say you
have a math library that uses and stl vector.  Also say you want to use a
graphics library that doesn't really support C++, maybe openGL.  It wants
C arrays. 
    The alternatives I've found were to convert all the time (hope you
don't need performance), or to use the address of the first element of an
STL vector for GL which, to my knowledge, isn't technical portable.  (I've
heard hints that this might change, but the standards committee isn't
known for their speed on such issues, and few compiler venders have been
quit to reach compliance.)
    It would be nice to define a vector-like class that fit the
stl::vector interface using polymorphism, but still let you get access to
an internal array, allow you to be compiant without the performance impact
of converting all over the place.  But alas, the design of the stl does
not allow for this. 
    I guess the ideal C++ solution would be to use a C++ graphics API, but
I have seen a good open standard that was portable as openGL that didn't
just subvert OO and give you a procedural GL wrapper that uses overloaded
functions that you pass objects into.  (Plib comes to mind.) 
    This might be a good chance to ask a question.  Does anyone know of a
good C++ graphics API that uses an OO interface and plays nicely with the
stl and other stl friendly libs?  I'll add the requirement that it be a
free (bsdish, lgpl, loath gpl for libs) library so that I may gpl the
program without being forced to do so.  Portability is a must also since
all the people I'd like to show off to are still stuck on a legacy
platform.  Any ideas?

Dan




More information about the tuxCPProgramming mailing list