[cxx-abi-dev] Parameter references in function types
Jason Merrill
jason at redhat.com
Mon Jun 14 17:10:08 UTC 2010
On 05/06/2010 03:48 PM, David Vandevoorde wrote:
> Let L be the number of function prototype scopes from the innermost one (in which the parameter reference occurs) up to (and including) the one containing the declaration of the referenced parameter. If the parameter declaration clause of the innermost function prototype scope has been completely seen, it is not counted (in that case -- which is perhaps the most common -- L can be zero).
I agree with the general idea, but would quibble with the specification;
the innermost scope should be #0, and the return type should be
considered part of the prototype. So:
> template<class T, class U> void f(T p, decltype(p)(*)(U p)); // L = 1
Yes.
> template<class T, class U> void f(T p, auto (*)(U p)->decltype(p)); // L = 0
Yes.
> template<class T> void f(T p, decltype(p)); // L = 1
L = 0.
> template<class T> void g(T p, decltype(p) (*)()); // L = 1
Yes.
> template<class T> void h(T p, auto (*)()->decltype(p)); // L = 1
Yes.
> template<class T> void i(T p, auto (*)(T q)->decltype(q)); // L = 0
Yes.
> template<class T> void j(T p, auto (*)(decltype(p))->T); // L = 2
L = 1.
> template<class T> void k(T p, int (*(*)(T p))[sizeof(p)]); // L = 1
Yes; sizeof(p) refers to the outer p.
Jason
More information about the cxx-abi-dev
mailing list