#include <iostream>

#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/for_each.hpp>

namespace a { namespace b {
    namespace x {
      int test1 = 1;
    }
    namespace y {
      int test2 = 2;
    }
    namespace z {
      int test3 = 3;
    }
  }
}

#define USE_NAMESPACES_IMPL( r, root, name ) \
  using namespace root :: name;

#define USE_NAMESPACES( root, names ) \
  BOOST_PP_SEQ_FOR_EACH( USE_NAMESPACES_IMPL, root, names )

USE_NAMESPACES( a::b, (x)(y)(z) )

int main() {

  std::cout << test1 << '\n';
  std::cout << test2 << '\n';
  std::cout << test3 << '\n';
  
  return 0;
}
