FW: Special functions in TR1
Ed Smith-Rowland
3dw4rd@verizon.net
Sat Dec 3 01:59:00 GMT 2005
| On 01/12/05 13:10, Smith-Rowland, Edward M (Contractor) wrote:
| >
| > Here's a schematic:
| >
| > template< typename Numeric >
| > Numeric __func( Numeric x )
| > {
| > if ( ! std::tr1::is_floating_point< Numeric >::value )
| > {
| > throw std::domain_error;
| > }
| >
| > if ( sizeof( Numeric ) == sizeof( double )
| > {
| > // Initialize for double algorithm.
| > }
| >
| > ...
| > }
|
| I would suggest that a compile-time error be produced instead of a runtime
| error for invalid template parameters. Something like the following.
|
| typedef typename __enable_if<result_type,
| is_floating_point<result_type>::value
| >::__type is_valid_type;
|
| Just, you know, in case you're serious about implementing these.
|
Right... I was brain dead there for a moment.
The run-time domain_error is for input variables out of range.
The argument types checking would be compile time of course.
--
Stephen M. Webb
**
More information about the Libstdc++
mailing list