|
Boost : |
Subject: Re: [boost] [result_of] now uses decltype on release branch
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-09-10 05:05:23
Eric Niebler wrote:
>> template < class , class = void >
>> struct result_of_aux
>> {};
>>
>> template < class F, class ...Args>
>> struct result_of_aux<F(Args...),
>> decltype(std::declval<F>()(std::declval<Args>()...), void ())>
>> {
>> typedef decltype(std::declval<F>()(std::declval<Args>()...)) type;
>> };
>
> What is void()? That's not any expression I recognize. It's a function
> type.
5.2.3 [expr.type.conv] p2
The expression T(), where T is a simple-type-specifier or typename-specifier
for a non-array complete object type or the (possibly cv -qualified)
void type,
creates a prvalue of the specified type, which is value-initialized ( 8.5; no
initialization is done for the void() case).
> Anyway, keep in mind that std::declval<F>()(...) could have an
> incomplete type, so you can't really use it in an expression.
> You should use it in decltype,
All the use of `std::declval<F>()(...)` is in decltype
and so I don't see any problem in the code.
Do you mean
struct result_of_aux<
F(Args...)
, decltype(std::declval<F>()(std::declval<Args>()...), void ())
>
can be a hard error?
Regards,
Michel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk