twice(twice(x))

K

Kiuhnm

I am having trouble with the function Add4Ptrs_v2.
#include <iostream>

#include <boost/type_traits.hpp>

#include <boost/mpl/vector.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/transform.hpp>
#include <boost/mpl/times.hpp>

using namespace boost; // ...
using namespace mpl; // ...

// Metafunction class.
struct metaf
{
template<typename T>
struct apply : public plus< int_<1>, T > {};
};

// Metafunction.
template<typename F, typename X>
struct twice : public apply< F, typename apply< F, X >::type > {};

// Metafunction: X -> X****
template<typename X>
struct Add4Ptrs
{
typedef typename twice< add_pointer<_>, typename
twice<add_pointer<_>, X>::type >::type type;
};

// Metafunction: X -> X****
template<typename X>
struct Add4Ptrs_v2
{
typedef typename twice< twice< add_pointer<_>, _ >, X >::type type;
};

int main()
{
typedef transform< vector_c<int,1,2,3>, metaf >::type res0;
// ok

typedef transform< vector_c<int,1,2,3>, plus< _, int_<1> > >::type
res1; // 3.1
typedef transform< vector_c<int,1,2,3>, times< _, _1 > >::type
res2; // 3.2
typedef Add4Ptrs<int>::type res3;
// 3.3
typedef Add4Ptrs_v2<int>::type res4;
// 3.4

std::cout << typeid(res0).name() << std::endl << std::endl;
std::cout << typeid(res1).name() << std::endl << std::endl;
std::cout << typeid(res2).name() << std::endl << std::endl;
std::cout << typeid(res3).name() << std::endl << std::endl;
std::cout << typeid(res4).name() << std::endl << std::endl;
}
<<<<

Kiuhnm
 
V

Victor Bazarov

Kiuhnm" <"kiuhnm03[ said:
I am having trouble with the function Add4Ptrs_v2.
#include <iostream>

#include <boost/type_traits.hpp>
[...]

You should consider Boost's online forums for questions about their
functionality. Here we talk standard C++ only.

V
 
K

Kiuhnm

Victor Bazarov ha scritto:
You should consider Boost's online forums for questions about their
functionality. Here we talk standard C++ only.

Ok, sorry.

Kiuhnm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top