breathe icon indicating copy to clipboard operation
breathe copied to clipboard

inline constexpr friends inject extra keywords

Open cjdb opened this issue 1 year ago • 4 comments

Steps to reproduce

  1. Follow Sy Brand's tutorial for setting up Breathe.
  2. Add the following to CatCutifier.h
/**
  A fluffy feline
*/
struct cat {
  /**
    Make this cat look super cute
  */
  void make_cute();

  /// some docs
  constexpr friend bool operator==(cat const x, int const y)
  {
    return true;
  }
};

Expected output

constexpr friend bool operator==(cat const x, int const y)

  some docs

Actual output

inline friend constexpr friend bool operator== (cat const x, int const y)

  some docs

inline should not be present at all, and friend should only appear once.

cjdb avatar May 16 '23 19:05 cjdb

@cjdb Could you also post the Doxygen XML definition for the operator==, curious to see what I looks like.

vermeeren avatar May 16 '23 19:05 vermeeren

Not entirely sure what you're after, so I've bundled everything from my doxygen/xml. I also checked the HTML and didn't see extra keywords. xml.zip

cjdb avatar May 16 '23 20:05 cjdb

I noticed while looking into #917 that friend is unconditionally being inserted if something is a friend. I'm not sure why it being constexpr impacts this, but commenting that line out seems to fix it (I haven't tested to see what happens in situations that aren't like the one above yet).

https://github.com/breathe-doc/breathe/blob/bf020a8c284929f48033c0c8fb9de37615d5c0c1/breathe/renderer/sphinxrenderer.py#L1982-L1983

Update: it looks as if friend constexpr works as intended, but constexpr friend does not.

cjdb avatar May 16 '23 21:05 cjdb

Hey everyone, thanks for making a great tool here in Breathe! @vermeeren any chance of getting #918 merged and into a release? It looks like this issue (and #917) have pending fixes that could go in.

vyasr avatar Nov 09 '23 20:11 vyasr