Created on 2009-10-05.00:00:00 last changed 171 months ago
[ The value<> helper function is a utility Daniel Krügler proposed in N2958. ]
[ These changes will require compiler support ]
Change [func.ret]:
template<class> class result_of; // undefined template<class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)> { public:typedefsee belowtype;};
Given an rvalue fn of type Fn and values t1, t2, ..., tN of types T1, T2, ... TN in ArgTypes respectivly, the type member is the result type of the expression fn(t1,t2,...,tN). the values ti are lvalues when the corresponding type Ti is an lvalue-reference type, and rvalues otherwise.The class template result_of shall meet the requirements of a TransformationTrait: Given the types Fn, T1, T2, ..., TN every template specialization result_of<Fn(T1,T2,...,TN)> shall define the member typedef type equivalent to decltype(RE) if and only if the expression RE
value<Fn>() ( value<T1>(), value<T2>(), ... value<TN>() )would be well-formed. Otherwise, there shall be no member typedef type defined.
Rationale:
Solved by 1270.
[
2010 Pittsburgh: Moved to NAD EditorialResolved, rationale added below.
]
I think the text about std::result_of could be a little more precise. Quoting from N2960...
[func.ret] Function object return types
template<class> class result_of; template<class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)> { public: typedef see below type; };Given an rvalue fn of type Fn and values t1, t2, ..., tN of types T1, T2, ... TN in ArgTypes respectivly, the type member is the result type of the expression fn(t1,t2,...,tN). the values ti are lvalues when the corresponding type Ti is an lvalue-reference type, and rvalues otherwise.
This text doesn't seem to consider lvalue reference types for Fn. Also, it's not clear whether this class template can be used for "SFINAE" like std::enable_if. Example:
template<typename Fn, typename... Args> typename std::result_of<Fn(Args...)>::type apply(Fn && fn, Args && ...args) { // Fn may be an lvalue reference, too return std::forward<Fn>(fn)(std::forward<Args>(args)...); }
Either std::result_of<...> can be instantiated and simply may not have a typedef "type" (-->SFINAE) or instantiating the class template for some type combinations will be a "hard" compile-time error.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-12-05 00:09:22 | admin | set | status: nad editorial -> resolved |
2010-10-21 18:28:33 | admin | set | messages: + msg1219 |
2010-10-21 18:28:33 | admin | set | messages: + msg1218 |
2010-10-21 18:28:33 | admin | set | messages: + msg1217 |
2010-10-21 18:28:33 | admin | set | messages: + msg1216 |
2010-10-21 18:28:33 | admin | set | messages: + msg1215 |
2009-10-05 00:00:00 | admin | create |