Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost TraitsType Question
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-10-04 14:17:44


Hi,

why don't you use overloading for this?

void setTag(short myVariable){
     //do something
}

void setTag(long myVariable){
     //do something
}

On 2012-10-04 19:58, Rawate, Vishal CIV NAVAIR-WD-5-2-7-1-1-0-E.,
527110E wrote:
> Hello,
>
> I am writing a function using templates in C++.I want to find the
> type of variable that is being to the function. I was wondering if I
> could use the Boost TypeTraits library or is there another library
> that I can use.
> I would highly appreciate any help.
>
> Thanking in advance.
>
> Vishal
>
>
> CodeSnipet:
>
> Template<typename T>
>
> Void setTag(T myVariable)
> {
> If(T == short)
> {
> Do something;
> }
>
> If(T == long)
> {
> Do something;
> }
>
> }


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net