Is it possible to instantiate these templates with my own type?

Ie. this is working fine:
#include <vsl/vsl_vector_io.txx>
#include <vbl/io/vbl_io_array_2d.txx>
VSL_VECTOR_IO_INSTANTIATE(vbl_array_2d<double>);

But when I try this:
VSL_VECTOR_IO_INSTANTIATE(vbl_array_2d<ValidType<double> >);

I get "no matching function call".  ValidType<> is simply a wrapper I wrote that contains a .Value that is the type of the ValidType template (in this case, double) and a bool Valid that indicates if the double should be considered "valid" or not. I have a << operator defined for this class (not sure if that matters?). What do I have to do to get it to write to a binary file (inside of a vbl_array_2d) with vsl?

Thanks,

David


On Thu, Mar 26, 2009 at 4:38 AM, Peter Vanroose <peter_vanroose@yahoo.co.uk> wrote:

David,

Actually I was wrong where it came to the correct name of that instantiation file: should have been vsl_vector_io+vnl_matrix_fixed+double.3.3--.cxx
I've now added that file to the svn repository.

It's indeed OK to put the instantiation code into the application using it. Depending on the compiler (or better: the linker settings related to "weak symbols") however, you could be getting "duplicate symbol" errors in the future, when some library also would have that instantiation (as will be the case after the above file got added to the vnl_io lib).

That explains why we (try to) use a "standard" file naming & file placement scheme for those instantiation files, just to avoid duplicates.
So if you follow the standard naming conventions, it should be fairly safe to put your private instantiations into the actual vxl directory: either nobody needs it and the file will remain in place when you upgrade vxl, or someone else created exactly the same file with exactly the same content and you're fine again.

Compilers often have options to turn auto-instantiation on. Disadvantage of this is that your object files (and libs and execs) will grow because of the duplicate instantiations. That explains why vxl has it turned off by default. (All of this out of what I remember from a few years ago; the current compiler versions may have changed this somewhat; I don't know the actual details, sorry.)

--      Peter.









     ___________________________________________________
Sök efter kärleken!
Hitta din tvillingsjäl på Yahoo! Dejting: http://ad.doubleclick.net/clk;185753627;24584539;x?http://se.meetic.yahoo.net/index.php?mtcmk=148783