Friday, September 2, 2016

Exercise 3-3 Abrahams & Gurtovoy

Turn T into T**** by using twice twice.

#include <boost/type_traits/add_pointer.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
template <class UnaryMetaFunctionClass, class Arg>
struct apply1
: UnaryMetaFunctionClass::template apply<Arg>
{};
template <class F, class X>
struct twice
: apply1<F, typename apply1<F,X>::type>
{};
struct add_pointer_f
{
template <class T>
struct apply : boost::add_pointer<T> {};
};
BOOST_STATIC_ASSERT((
boost::is_same<
twice<add_pointer_f,
twice<add_pointer_f, int>::type>::type
, int****
>::value
));
int main()
{
return 0;
}
view raw 3d3.cpp hosted with ❤ by GitHub

No comments:

Post a Comment