Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > generic solution to functions that differ only by 'f' (float) and 'd' (double)

Reply
Thread Tools

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

 
 
ma740988
Guest
Posts: n/a
 
      04-08-2006

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.

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      04-08-2006
ma740988 wrote:

> 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.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Aside from delta cycles and/or resolution functions, how can the effective value of a signal differ from a driving signal of its? Colin Paul Gloster VHDL 0 01-11-2007 01:31 PM
TableAdapter differ with win and web application. ad ASP .Net 0 12-01-2005 09:04 PM
generic functions(template functions) Tony Johansson C++ 3 08-16-2005 10:33 AM
What is differ between Application.Run and .ShowDialog() ? alex9128 ASP .Net 2 08-10-2005 10:25 PM



Advertisments