function template

Jan 8, 2010 at 2:41pm
Hello

How do i return true or false from a function template?
1
2
3
4
5
6
7
8
9
10
11
12
13
template <class T>

T f(T a,T b)
{
   if(a == b)
    {
      //true
    }else
    {
      //false
    }
}
Last edited on Jan 8, 2010 at 2:42pm
Jan 8, 2010 at 2:45pm
1
2
3
4
5
6
7
template <class T> bool foo(T a,T b)
{
  if(a == b)
    return true;
  else
    return false;
}
Last edited on Jan 8, 2010 at 2:45pm
Jan 8, 2010 at 2:56pm
template <class T> bool foo(T a,T b) { return a == b; }
Jan 8, 2010 at 2:57pm
haha nice one!
Jan 8, 2010 at 5:40pm
Which is further simplified as

a == b
Jan 8, 2010 at 6:35pm
lol
Jan 8, 2010 at 8:03pm
Nice!
Last edited on Jan 8, 2010 at 8:03pm
Topic archived. No new replies allowed.