[Home]CPPTM Answers - Exercise 3-3

BOOST WIKI | RecentChanges | Preferences | Page List | Links List

No diff available--this is the first major revision. (minor diff, author diff)
 // (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).


BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited May 7, 2005 3:23 pm (diff)
Search:
Disclaimer: This site not officially maintained by Boost Developers