a2x

时间:2023-11-10 08:19:20

a2x

#include <typeinfo>
template <typename T>
bool a2x( T& _f , char* p)
{
if( !p )
return false ; char* q = p ;
while( q != '\0')
{
if( *q == '-' && *(q+) >= '' && *(q+)<= '' )
{
break ;
} if( *q >= '' && *q <= '' )
break ; q++ ;
}
if( q =='\0')
return false ; if(typeid(float).name() == typeid(_f).name() )
sscanf(q,"%f",&_f );
else if(typeid(int).name() == typeid(_f).name() )
sscanf(q,"%d",&_f );
else if(typeid(long).name() == typeid(_f).name() )
sscanf(q,"%ld",&_f );
else if(typeid(double).name() == typeid(_f).name() )
sscanf(q,"%lf",&_f );
else
return false ; return true ;
}

相关文章