473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

compile time detection of multiple template class usage

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<inta and c3::member_c_2
declaration to TmplWrp<c2member_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.

Jun 27 '07 #1
0 1045

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
1
by: Leon | last post by:
Hi all. I'm using a thrid-party software library that uses two tag classes (Tag_true and Tag_false) to flag if certain operations are available in a (template) class. Now I think the idea...
0
by: Gianni Mariani | last post by:
Below is an example of how to do static type-checking of an erroneous set of input masks. The drawback is that it's a little too verbose and non-trivial to understand and to make it truly I'd...
19
by: Rahul | last post by:
Hi, Is there a way to find the offset of a class member at compile time. e.g. class A{ int i; int j; char c; }; Here the offset of c = 8 bytes from the start of an object of A (assuming 4...
14
by: Dave Rahardja | last post by:
Is there a way to generate a series of statements based on the data members of a structure at compile time? I have a function that reverses the endianness of any data structure: /// Reverse...
1
by: bodeman72 | last post by:
Hello, I was wondering if someone would be able to help me with the following compile error In constructor Queue<T>::Queue() : no matching function call to jobType::jobType() candidates are...
27
by: CodeMonk3y | last post by:
gotta question on sizeof keyword does the sizeof keyword calcuates the size at compile time or run time ?? -- Posted on news://freenews.netfront.net - Complaints to news@netfront.net --
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.