判断是否为浮点数类型
#include <iostream>
#include <string>
#include <functional>
#include <type_traits>
void void_print()
{
return;
}
bool bool_print()
{
return false;
}
char char_print()
{
return 'a';
}
unsigned char uchar_print()
{
return static_cast<unsigned char>(10);
}
short short_print()
{
return 100;
}
unsigned short ushort_print()
{
return 100;
}
int int_print()
{
return -1;
}
unsigned int uint_print()
{
return 0;
}
long long_print()
{
return 10;
}
unsigned long ulong_print()
{
return 10;
}
long long longlong_print()
{
return 10;
}
unsigned long long ulonglong_print()
{
return 10;
}
float float_print()
{
return 1.0f;
}
double double_print()
{
return 1.0;
}
std::string string_print()
{
return std::string("abc");
}
const char* chs = "const char";
const char* const_char_print()
{
return chs;
}
class A
{
public:
A()
{
a = false;
b = 'a';
c = static_cast<unsigned char>(10);
d = 11;
e = 12;
f = 1;
g = 2;
h = 3;
i = 4;
j = 5;
k = 6;
l = 7.0f;
m = 8.0;
n = "std::string";
o = "const char";
}
virtual ~A()
{
std::cout << __FUNCTION__ << ": " << __LINE__ << ": run here " << std::endl;
}
void void_print()
{
return;
}
bool bool_print()
{
return a;
}
char char_print()
{
return b;
}
unsigned char uchar_print()
{
return c;
}
short short_print()
{
return d;
}
unsigned short ushort_print()
{
return e;
}
int int_print()
{
return f;
}
unsigned int uint_print()
{
return g;
}
long long_print()
{
return h;
}
unsigned long ulong_print()
{
return i;
}
long long longlong_print()
{
return j;
}
unsigned long long ulonglong_print()
{
return k;
}
float float_print()
{
return l;
}
double double_print()
{
return m;
}
std::string string_print()
{
return n;
}
const char* const_char_print()
{
return o;
}
public:
virtual A* creat_object()
{
return new A();
}
virtual std::string print_typename()
{
return std::string("A");
}
public:
bool a;
char b;
unsigned char c;
short d;
unsigned short e;
int f;
unsigned int g;
long h;
unsigned long i;
long long j;
unsigned long long k;
float l;
double m;
std::string n;
const char* o;
};
class B : public A
{
public:
B() : A()
{
}
public:
virtual A* create_object()
{
return new B();
}
virtual std::string print_typename()
{
return std::string("B");
}
};
int main()
{
std::cout << "This Dome: is_floating_point" << std::endl;
bool a;
char b;
unsigned char c;
short d;
unsigned short e;
int f;
unsigned int g;
long h;
unsigned long i;
long long j;
unsigned long long k;
float l;
double m;
std::string n;
const char* o = "const char";
a = false;
b = 'a';
c = static_cast<unsigned char>(10);
d = 11;
e = 12;
f = 1;
g = 2;
h = 3;
i = 4;
j = 5;
k = 6;
l = 7.0f;
m = 8.0;
n = "std::string";
// Step1:
if(std::is_floating_point<void>::value)
{
std::cout << __LINE__ << ": is floating point type " << std::endl;
}
else
{
std::cout << __LINE__ << ": isn't floating point type" << std::endl;
}
if(std::is_floating_point<bool>::value)
{
std::cout << __LINE__ << ": is floating point type " << std::endl;
}
else
{
std::cout << __LINE__ <<