function template

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
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
template <class T> bool foo(T a,T b) { return a == b; }
haha nice one!
Which is further simplified as

a == b
lol
Nice!
Last edited on
Topic archived. No new replies allowed.