In all the new IDEs when using open and close curly brackets the auto-formatting usually indents, and uses the extendable block (with the + sign) even if it is not necessary.
For example, I like when all my functions have there own little extendable block but when I place them all in a namespace it makes unnecessary indent and my functions no-longer have the block i.e.

namespace my {
    int myfunc() {
        code
        more code
    }
}

instead of preferred version --

namespace my {
int myfunc() {
    code
    more code
}
}

It always bothered me, but now I randomly thought of a solution, using defines!

#define OPENBRACKET {
#define CLOSEBRACKET }

namespace my OPENBRACKET
int myfunc() {
   code
   more code
    }
CLOSEBRACKET

I was so happy, I had to share it with someone :D.
P.S. I love the C-styled #defines :icon_evil:

Recommended Answers

or you can write the namespace contents and than wrap it all in the namespace u wanted

Jump to Post

All 2 Replies

haha.. Thanks for sharing :)

I surely can use it somewhere.

or you can write the namespace contents and than wrap it all in the namespace u wanted

commented: good idea +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.