Benjamin Smedberg wrote:
1) Bracing of method bodies in a C++ class declaration

Currently, C++ method bodies inline within a class declaration are
documented to start on the next line, e.g.

class B
{
public:
void Method()
{
// Inline body brace is on the next line, column 2
}
};

Mozilla code widely puts the opening bracde of inline bodies such as
this on the end of the declaration line, and I want to make sure we're
in agreement to fix this.

I don't mind too much.

If we do make it same-line, it would be nice to write down how to handle empty inline method/constructor bodies, too:

  class A
  {
    A(int aMember)
      : mMember(aMember) {
    }
  };

or

  class A
  {
    A(int aMember)
      : mMember(aMember) { }
  };

or

  class A
  {
    A(int aMember)
      : mMember(aMember) {}
  };

Also, I have seen (and written) short one-line method bodies like this:

  class A
  {
    bool IsFlagSet() const
      { return mFlag; }
  };

which I guess should be invalid with brace-on-first-line. I think I actually prefer (and don't mind the churn that Ehsan mentions if we rename things)

  class A
  {
    bool IsFlagSet() const { return mFlag; }
  };

if it's short enough, and if not, then we go to:

  class A
  {
    bool IsFlagSet() const {
      return mFlag;
    }
  };

2) indentation of visibility within a class declaration

In the above example, "public" is at the same indentation level as the
class. This is common in new code, but I want to call it out.

3) placement of the colon and commas for C++ member initializers

MyClass::MyClass()
: mMember1(foo)
, mMember2(foo)
{
// function body
}

Existing usage is all over the place. I personally have found this style
to produce the least number of merge conflicts when applying patches to
these kinds of methods, but again I want to make sure we're in agreement.

Agree.

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to