<div dir="ltr">I'd like a tool that could move (explicit or implicit inline) function bodies of C++ class methods declared in the class definition, to just after the class.  For example:<br><br><div><div>   struct X</div><div>   {</div><div>      bool foo( int x = 1 )</div><div>      {</div><div>         return true ;</div><div>      }</div><div><br></div><div>      inline bool moo( int x, int y )</div><div>      {</div><div>         return true ;</div><div>      }</div><div><br></div><div>      static bool boo(void)</div><div>      (</div><div>         return true ;</div><div>      )</div><div>   } ;</div></div><div><br></div><div>and produce rewritten code like:</div><div><br></div><div><div>   struct X</div><div>   {</div><div>      inline bool foo( int x = 1 ) ;</div><div><br></div><div>      inline bool moo( int x, int y ) ;</div><div><br></div><div>      static inline bool boo( void ) ;</div><div>   } ;</div><div><br></div><div>   inline bool X::foo( int x )</div><div>   {</div><div>      return true ;</div><div>   }</div><div><br></div><div>   inline bool X::moo( int x, int y )</div><div>   {</div><div>      return true ;</div><div>   }</div><div><br></div><div>   inline bool X::boo( void ) ;</div><div>   (</div><div>      return true ;</div><div>   )</div></div><div><br></div><div>Having done this manually a number of times (to decouple class definitions from implementation, and reduce #include tree sizes), the steps are:<br><br>1) add inline in the declaration of the function if required.</div><div>2) delete the body at the declaration point.</div><div>3) add a semicolon.</div><div>4) move the body to after the class (i.e. as prep for manually moving problematic inlines elsewhere that introduce dependencies)</div><div>5) remove any static specifier from the relocated body.</div><div>6) make sure there's an inline specifier in the relocated function body.</div><div>7) remove any default parameters that should only be included with the prototype.</div><div>8) add the class specifier (X:: in the example above)</div><div><br></div><div>This seems like a highly automatable task given the libtooling infrastructure, and it wouldn't suprise me if a rewriter like this has been thought about as a companion for google's include_what_you_use libtooling tool.</div><div><br></div><div>Before trying to implement such a beast, I thought I'd ask if anybody knows of such a tool.  If no such tool is known, perhaps somebody point me to an example (or examples) of a transformation tools that have one or more aspects of the rewriting steps above.</div><div><br></div>-- <br><div class="gmail_signature">Peeter</div>
</div>