|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-01-12 19:52:02
"Paul Mensonides" <pmenso57_at_[hidden]> writes:
> ----- Original Message -----
> From: "David Abrahams" <dave_at_[hidden]>
>
>> > I didn't know that this was legal:
>> >
>> > template<class T> struct identity {
>> > typedef T type;
>> > };
>> >
>> > template<class T> void func(const T&, typename identity<T>::type* = 0);
>> >
>> > int main() {
>> > func(10);
>> > return 0;
>> > }
>>
>> Sure, T is deducible due to the first argument.
>
> Cool, I learn something every day. I assume, though, that if I attempted to
> actually use the second parameter it would become non-deducable, right?
No, as long as identity<T>::type* matches the type of the parameter
you pass, everything still works.
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk