This questions is based on
I would like to emulate
namespace foo::bar::baz {
with a macro before C++17 arrives.
I was thinking in the lines of:
#define BOOST_PP_VARIADICS
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/fold_left.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#define OP(s, state, x) BOOST_PP_CAT(state, BOOST_PP_CAT( { namespace, x )) {
#define NS(...) namespace BOOST_PP_SEQ_FOLD_LEFT(OP, BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)))
NS(foo, bar, baz)
Based on the second link, but this gives me:
namespace foo { namespacebar { namespacebaz {
How do I add a space between namespace
and the identifiers?
Edit:
If you can make a macro so that ns(foo::bar::baz)
expands to namespace foo { namespace bar { namespace baz {
, even better.