[c++-concepts] constrained friends redux

Jason Merrill jason@redhat.com
Wed Oct 2 16:50:00 GMT 2013


On 10/02/2013 09:05 AM, Andrew Sutton wrote:
> +          // Do not permit the declaration of constrained friend
> +          // function declarations. They cannot be instantiated since
> +          // the resulting declaration would never match the definition,
> +          // which must be a non-template and cannot be constrained.

You're in the template-id code here, so "must be a non-template" is 
confusing:

template <class T> void f();

struct A {
   friend void f<int>(); // matches a template
};

Perhaps you mean that it must match a fully-instantiated function, so 
any constraints on the templates were considered during 
determine_specialization.

> +      error("constrained friend does not depend on template parameters");

Space before (.

> +// Returns true if FN is a non-template member function.
> +static inline bool
>  is_non_template_member_fn (tree fn)
>  {
>    return DECL_FUNCTION_MEMBER_P (fn) &&
> @@ -1829,6 +1829,21 @@ is_non_template_member_fn (tree fn)
>           !DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (fn));
>  }
>
> +// Returns true if FN is a non-template friend definition.
> +static inline bool
> +is_non_template_friend (tree fn)

These names/comments fail to make it clear that they return true only 
for non-template members/friends *of class template specializations*. 
So my preference would be to open-code them into 
is_constrainable_non_template_fn.

Jason



More information about the Gcc-patches mailing list