|
Boost : |
From: Andy Little (andy_at_[hidden])
Date: 2004-04-03 05:00:18
"Rozental, Gennadiy" <gennadiy.rozental_at_[hidden]> wrote
[example snipped]
> And give me single example where second design is preferable to first?
I agree absolutely. And with the input from contributions this thread under
my belt I shall revisit numeric::converter. There are a large number of
params there .. I guess you think too many?
> Actually I think the best design would look like this:
[example snipped]
Yes this is potentially cool. Unfortunately closest I could get was:
struct multiply_t
{
template< typename A , typename B >
struct sig : multiply_traits<A,B> {};
// fails because A and B cannot be deduced from a or b in the
//function parameters(VC7.1, gcc 3.2)
#if 0
template< typename A , typename B >
typename sig<A,B>::result_type
operator ()( typename sig<A,B>::first_argument_type a,
typename sig<A,B>::second_argument_type b )
{
return a * b;
}
#else
// ok
template< typename A , typename B >
typename sig<A,B>::result_type
operator ()( A const& a,B b ) //whatever
{
return a * b;
}
#endif
}multiply;
The unnammed namespace scheme I should think more about ... but off-topic.
regards
Andy Little
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk