This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [c++-concepts] constrained friends redux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]