[utility]proposal for a small utility of namespace

I like c++ and boost,but write namespace is a boring work for brace-matching. So I write a small util with boost.preprocessor, like below: #ifndef BOOST_NAMESPACE_UTILITY_HPP_ #define BOOST_NAMESPACE_UTILITY_HPP_ #include <boost/preprocessor/seq/for_each.hpp> #define _PP_NS_BEGIN_FUNC(r,data,elem) namespace elem { #define _PP_NS_END_FUNC(r,data,elem) } #define BOOST_BEGIN_NAMESPACE(SEQ) \ BOOST_PP_SEQ_FOR_EACH(_PP_NS_BEGIN_FUNC, ~, SEQ) #define BOOST_ END_ NAMESPACE (SEQ) \ BOOST_PP_SEQ_FOR_EACH(_PP_NS_END_FUNC, ~, SEQ) #endif //BOOST_NAMESPACE_UTILITY_HPP_ Then the code can be more clear and easy-reading: BOOST_BEGIN_NAMESPACE((boost)(asio)(ip)) //namespace boost{namespace asio{namespace ip{ ... //to something BOOST_END_NAMESPACE((boost)(asio)(ip)) //}}} c++11 inline namespace also can work: inline BOOST_BEGIN_NAMESPACE((detail)) ... //to something BOOST_END_NAMESPACE((detail)) I wander to know whether this util could be a part of boost. Thanks a lot.

On Mon, Feb 25, 2013 at 10:11 AM, law chrono <chronolaw@gmail.com> wrote:
I like c++ and boost,but write namespace is a boring work for brace-matching.
So I write a small util with boost.preprocessor, like below:
Then the code can be more clear and easy-reading:
BOOST_BEGIN_NAMESPACE((boost)(asio)(ip)) //namespace boost{namespace asio{namespace ip{
... //to something
BOOST_END_NAMESPACE((boost)(asio)(ip)) //}}}
c++11 inline namespace also can work:
inline BOOST_BEGIN_NAMESPACE((detail)) ... //to something BOOST_END_NAMESPACE((detail))
I wander to know whether this util could be a part of boost.
IMHO, this just unnecessarily obfuscates the code, with no apparent benefit (the closing braces are even shorter quite a bit). Also, I expect this slow down compilation a little.
participants (3)
-
Andrey Semashev
-
Jonathan Wakely
-
law chrono