Hello,
I have a .cpp file which a sort of top level
driver.
I have say 100 different
struct param_i {...};
where 1<=i<=100
Each param_i is defined in a param_i.hpp and
param_i.cpp invokes metafunctions to obtain
typedef fusion< variant<
vector<double>, triplet<double>, pair<double>, double>,
variant<...>, ...,
variant<...> >
seq_i_t;
this sequence type is visible only in the
param_i.cpp, not the header file. Generation of this sequence is
The size of these sequences = number of
members of param_i.
The toplevel driver and other .cpp need to move
instances of these types around to other .cpp.
To avoid having the compiler call the metafunctions
for these middle translation units, but only at the generating .cpp and at the
consuming .cpp, I created a tag
struct fusion_seq_tag {};
typedef <typename
Arg>
struct make_fusion_seq_i
{
typedef
<undefined> type;
};
typedef <typename
Arg>
struct make_fusion_seq_tag
{
typedef typename
make_fusion_seq_i<Arg>::type base_type;
struct type :
fusion_seq_tag, base_type {
type(...) : base_type(...) {}
};
};
return
smart_ptr<fusion_seq_tag>( new make_fusion_seq_tag<...>::type
);
// this was the generating .cpp
The function returns
smart_ptr<fusion_seq_tag> which can move around in other .cpp without any
metaprogramming
until reaching the consuming .cpp
Is this type erasure?
I don't know how I can get the actual type back in
the consuming .cpp if I don't know the originator but if I know only the shape
of the fusion sequence. How to dynamic cast the type back to its unerased
type?
If I know the originator .cpp then I would know the
exact fusion sequence and therefore I would just dynamic_cast the
fusion_seq_tag.
Regards,