compile time detection of multiple template class usage

A

alexandru.nicau

Hello All,
I've got this huge class hierarchy (the naive solution to the
following cannot be accepted). Throughout the code I need to
instantiate a template wrapper class at several locations. Easy does,
I change the code and wrap all the members I want into TmplWrp. Assume
it's bad if I've got some member wrapped into TmplWrp then one of its
descendants (think of class members - not of inheritance) also wrapped
into TmplWrp.

Can you think of any solution where I'll be able to determine such
pairs or even chains (the wrappee contains members, the members
contain other members to a point where there is another object wrapped
with TmplWrp) at compile time? Runtime can be easily implemented by
using some static.

The template wrapper:

template <class T>
class TmplWrp
{
T local;
public:
TmplWrp(const T cp = T()) : local(cp)
{
}

T &Get()
{
return local;
}
};

Existing class hierarchy:

class c1
{
int a;
};

class c2 : public c1
{
int b;
};

class c3
{
int c;
c2 member_c_2;
};

If I change c1::a declaration to TmplWrp<int> a and c3::member_c_2
declaration to TmplWrp<c2> member_c_2 we're in the invalid situation
where I need warning. But if only c1::a and c2::b are wrapped in
TmplWrp we're ok: no warning should be given because the two are on
the same level (inheritance).


Thanks in advance,
Alex.
 

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,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top