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++ PATCH] Fix 87



! /* D is a constructor or overloaded `operator='.
!    Returns 0 if it is not a copy ctor or copy assignment operator.
!    Return 1 if it is a non-constant copy ctor or copy assignment
!    operator.
!    Return 2 if it is a constant copy ctor or copy assignment
!    operator.
!    Return -1 if it is a by-value argument.  */

Improve this to:

  /* D is a constructor or overloaded `operator='.

     Let T be the class in which D is declared. Then, this function
     returns:

     -1 if D has a first parameter of type `T'.  (Such a function is
         not a copy constructor or assignment operator.)
     0  if D is not a copy constructor or copy assignment operator.
     1  if D is a copy constructor or copy assignment operator whose
        first parameter has type `const T&'.
     2  if D is a copy constructor or copy assignment operator whose
        first parameter has type `T&'.

     Therefore, this function can be used as a predicate like this:

       if (copy_fn_p (d) > 0)
         {
            /* D is a copy constructor or copy assignment operator. */
         }

     */

Rationale: this documentation makes things easier to understand; you
don't need to know the "ctor" abbreviation, you don't need to know
what a "constant copy constructor" is (that's not a term from the
standard), and you can easily see how this function is a predicate.

Why do we need to check DECL_FUNCTION_MEMBER_P here?  A constructor
or assignment operator can only be defined in a class.  So, shouldn't
we just assert that?

Add a comment above the DECL_TEMPLATE_INFO with a reference to the
standard so that we know why we're rejecting templates.

OK with those changes.

Thanks,

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


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