[ create a new paste ] login | about

Link: http://codepad.org/iIkOPE5Z    [ raw code | output | fork ]

C++, pasted on Dec 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <limits>

template <typename T>
std::string check()
{
    T def = T(),  // initialized with 0
      min = std::numeric_limits<T>::min(),
      max = std::numeric_limits<T>::max();
    return min < def && def < max ? "true" : "false";
}

int main()
{
    std::cout 
        << "int: " << check<int>() 
        << ", double: " << check<double>() 
        << std::endl;
    return 0;
}


Output:
1
int: true, double: false


Create a new paste based on this one


Comments: