473,796 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<c2membe r_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 1065

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

Similar topics

60
7310
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 The detector requires javascript 1.0 to work. This translates to netscape 2.0 and IE 3.0 (although maybe IE 2.0 also works with it)
6
3334
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 my particular application. One of the advantages is that the _compiler_ can force inner matrix dimensions used in multiplication to agree. A _complie-time_ error will be triggered if you write A * B and the number of coluns in A does not equal the...
1
1672
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 behind them is to be able to perform compile-time checks, but I don't understand how... These tag classes are defined as empty structs, i.e.: struct Tag_true {};
0
1325
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 like to hear if you think this is overboard or you'd like to see more code like this ? ------------------------------------------------------------------------
19
8771
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 byte int). Can it be done at compile time. Thanks in advance
14
4211
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 the endianness of a data structure "in place". template <typename T> void reverseEndian(T&); Using boost, it is possible to provide the default implementation for all POD
1
1287
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 jobType::jobType(const jobType&) jobType::jobType(bool, int) since I dont have anything that requires a deep copy or copy constructor this is confusing the heck out of me. Any sugestions would be greatly appreciated. The code follows <I am aware...
27
5612
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
5774
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 compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template classes. One is List1, the other one is ListNode. The codes are below: // test-linked-list.cpp :...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.