typename replace_compoundtype::type,
typename replace_simpletype::type >::type type;
};
int _tmain(int argc, _TCHAR* argv[])
{
// 2.1 练习题
// simple类型测试
{
// 对ref添加 add_volatile / add_const 那么将保持原类型输出
float f = (float)0.1;
boost::add_volatile::type i = f;
boost::add_const::type i2 = f;
replace_type::type f1 = 0; // float
replace_type::type f2 = 0; // const float
replace_type::type f3 = 0; // volatile float
replace_type::type f4 = 0; // const volatile float
replace_type::type f5 = f; // volatile float& == float&
replace_type::type f6 = 0; // const float
replace_type::type f7 = 0; // const float
}
{
float f = (float)0.1;
volatile float & ff = f;
replace_type::type f1 = 0; // float*
replace_type::type f2 = 0; // const float*
replace_type::type f3 = 0; // volatile float*
replace_type::type f4 = 0; // const volatile float*
replace_type::type f5 = f; // volatile float& = float&
replace_type::type f6 = f;// const float&
replace_type::type f7 = 0; // const float**
f=1.0;
}
{
float f = (float)0.1;
replace_type::type f1 = f; // float&
replace_type::type f2 = 0; // const float&
replace_type::type f3 = f; // volatile float&
replace_type::type f4 = 0; // const volatile float&
replace_type::type f5 = 0; // volatile float*
replace_type::type f6 = 0;//const float*
replace_type::type f7 = f; // const float&
f=1.0;
}
// 函数替换
{
float f = 0.;
replace_type::type f1; // float& (*)()
replace_type::type f2; // float& (*)(float)
replace_type::type f3; // float& (*)(float)
replace_type::type f4; // float& (*)(cv float&)
f = 1.0;
}
return 0;
}