#include <iostream>
#include <boost/typeof/typeof.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
#define MAKE_CONST(n) \
if (bool BOOST_PP_CAT(n, _cond) = true) \
for ( \
boost::add_reference< \
boost::add_const< \
boost::remove_reference<BOOST_TYPEOF(n)>::type \
>::type \
>::type \
BOOST_PP_CAT(n, _dummy) = n, \
n = BOOST_PP_CAT(n, _dummy); \
BOOST_PP_CAT(n, _cond); \
BOOST_PP_CAT(n, _cond) = false \
) \
/**/
int main()
{
int a = 5;
MAKE_CONST(a) {
std::cout << a;
// a = 3;
}
}