// (by Ariel Badichi) #include <boost/static_assert.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/type_traits/add_pointer.hpp> #include <boost/mpl/placeholders.hpp> #include <boost/mpl/apply.hpp>
namespace mpl = boost::mpl; using namespace mpl::placeholders;
template<typename F, typename T> struct twice : mpl::apply<F, typename mpl::apply<F, T>::type> {};
int main() { typedef twice<boost::add_pointer<_>, int>::type ppint; typedef twice<boost::add_pointer<_>, ppint>::type ppppint;
BOOST_STATIC_ASSERT((boost::is_same<ppppint, int ****>::value));
return 0; }
This code doesn't work in versions of Boost prior to 1.32 (I mention this because 1.31 is the standard version you get when you use apt-get in the latest version of Ubuntu).