My C++ indentation style. I'm still working on it, but some ideas might be useful for you.
I use headlines to easily find a position in the code when scrolling up and down. My headlines end at line 80. There are different ways of writing these headlines - the headline itself framed in horizontal lines, the chapter framed this way, or just a horizontal line on top of the headline..
//===============================================================// MyClass//===============================================================class MyClass { // //------------------------------------------------------------- // MyClass - member functions //------------------------------------------------------------- // void dosomething() { ... } // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // MyClass::foo() // foo is my favourite function name void foo() { // ... }};
I put my opening brace behind the function name, and try to not use it as a first character. Sometimes I do the same with large argument lists of functions or templates.
Statements like public:, or case xxx: are indented with half tab size. Typical tab size I use is 2 spaces. I always tick "replace tabs with spaces" - this is more a matter of bad experiences with tabs, I don't recommend it as the better solution.
Empty lines in a function or class are filled with comment slashes to maintain the optical flow of line beginnings. This way it's easy to find the start and end of a block. I put these 'decorated' empty lines where it seems appropriate.
I still didn't find the perfect solution for templates, and for defining inheritance. For the class template I define here, I put the ending brace of the template argument list in front of the class header, so the class template can't be confused with a usual non-template class.
//---------------------------------------------------------------// MyClassTemplatetemplate< class Base, class T, template<class> class TT, bool B> class MyClassTemplate : public Base { // public: // template<int Size> T* memberfunction( TT<T> arg1, float arg2, float arg3 ) { ... if(true) { see_what_happens(); } else { see_nothing(); } }}; // MyClassTemplate//---------------------------------------------------------------