This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: FW: Special functions in TR1
- From: Ed Smith-Rowland <3dw4rd at verizon dot net>
- To: stephenw at xandros dot com, libstdc++ at gcc dot gnu dot org
- Date: Fri, 02 Dec 2005 20:59:43 -0500
- Subject: Re: FW: Special functions in TR1
| 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
**