generic solution to functions that differ only by 'f' (float) and 'd' (double)

M

ma740988

Given:
void mxvmvd(double *pv1, long ninc1, double *pso, long n);
void mxvmvf( float *pv1, long ninc1, float *pso, long n);

How would I write a generic solution (template version) that'll call
the appropriate function based on the float or double type?
I've got vendor API's that has two separate functions that differ only
by 'f' (float) or 'd' (double). My intent is to put a wrappers around
these functions. I tempted to do a typeid 'check' but I'm unsure if
that's necessary/is the right approach.

Thanks in advance.
 
P

Phlip

ma740988 said:
void mxvmvd(double *pv1, long ninc1, double *pso, long n);
void mxvmvf( float *pv1, long ninc1, float *pso, long n);

How would I write a generic solution (template version) that'll call
the appropriate function based on the float or double type?
I've got vendor API's that has two separate functions that differ only
by 'f' (float) or 'd' (double). My intent is to put a wrappers around
these functions. I tempted to do a typeid 'check' but I'm unsure if
that's necessary/is the right approach.

You could use a template, but all you need is an overload:

void mxvmv(double *pv1, long ninc1, double *pso, long n)
{ mxvmvd(pv1, ninc1, pso, n); }
void mxvmv( float *pv1, long ninc1, float *pso, long n);
{ mxvmvd(pv1, ninc1, pso, n); }

You are looking at a C-style overload, so the simplest wrapper is a real C++
overload.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top