|
Boost : |
From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2004-01-08 05:40:59
Anatoli Tubman wrote:
> On Wednesday 07 January 2004 11:53, Daniel Frey wrote:
>
>>Definitly. Why isn't the current operator ^ spelled ~ anyway? Then ^
>>could have the right precedence and meaning. Think of m/s^2. Damn
>>C-ompatibility ;)
>
> Alas, this won't help because m^2 and m^3 should have different types.
> One needs an ability to overload on integral constant expressions:
Yup. I also mentioned something like that for the constant library in a
post. My idea is:
void f( int i ) // #1
{
// Used if f is called with a non-ICE
}
template< int I > void f( const int I ) // #2
{
// Used if f is called with an ICE != 2
}
template<> void f<2>( const int ) // #3
{
// Specialized if f is called with an ICE == 2
}
int main()
{
const int i = 2;
f(i); // calls #1
f(42); // calls #2
f(2); // calls #3
}
AFAICS this extension won't break any existing (legal) code. I'm taking
this to csc++ now as it is OT for boost...
Regards, Daniel
-- Daniel Frey aixigo AG - financial solutions & technology Schloß-Rahe-Straße 15, 52072 Aachen, Germany fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99 eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk