Given a set of classes
class A { enum [ ID = 0x0001} };
class B { enum [ ID = 0x0002} };
class B { enum [ ID = 0x0004} };
I wish to generate a composite class, perhaps using something like
Alexandrescu's typelists
(pseudo-code:)
template<class TList>
class Composite : TList
{
enum {ID = SumID<TList>::r esult}
};
typedef composite<TYPEL IST(A,B,C)> CompABC; // ID == 0x0007
Of course, the trivial A, B and C classes above would have data members
to make Composite meaningful, but the really important issue is
Composite's ID member, the value of which must be unique to the
combinations of components.
Thus, there are two parts to this. One, generating a linear inheritance
hierarchy from the typelist; and two, summing up the components' ID
values as the ID value of the generated composite.
Though I know exactly what I need I've so far (due to my inexperience
with metaprogramming ) failed to implement this. I've tried using
Alexandrescu's Loki and BoostMPL, but am stymied. Any help would be
deeply appreciated! 0 1453 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mohammad |
last post by:
Hi,
Is it possible to disable a method of a template class depending on
the typename at compile time?
thanks!
|
by: Gonçalo Rodrigues |
last post by:
Hi all,
(note: newbie alert)
Suppose you have a hierarchy of objects that you deal with via smart
pointers, e.g. something like:
template<typename T>
class Ref {
private:
|
by: n.torrey.pines |
last post by:
I have the following tree definition:
template<typename T>
struct tree {
T first;
vector<tree<T second; // branches
};
which compiles successfully. What I'd like to do though is to use
another template like 'pair', because I might have a bunch of useful
|
by: Joe |
last post by:
Hi,
I found a concept named template metaprogramming that can be used in C+
+ code at compile-time. I am a beginner at C++. But I am a programmer
on the .NET platform. Do you know if template metaprogramming is
supported in C# (.NET)? For reference I found it:
http://en.wikipedia.org/wiki/Template_metaprogramming.
Thanks to all.
|
by: Ted |
last post by:
I have cross posted this to comp.lang.c++ and to sci.math.num-
analysis
in the belief that the topic is of interest to some in both groups.
I am building my toolkit, in support of my efforts in producing high
performance C++ code; code that is provably correct. The issue here
is orthogonal to the question of expression templates, which at
present seem to me to be relatively simple.
| |
by: Alan Woodland |
last post by:
I've been trying out more template metaprogramming ideas with typelists
(mostly for personal learning, I'm aware boost most probably provides
this facility already), and I've run into this small problem here.
Comeau online (without C++0x, in strict mode) accepts this example
pasted here, (apologies for the length of it). Unfortunately G++ (3.4,
4.1, 4.2) doesn't, and complains about index_find being private. The
exact error it gives is:...
|
by: suman.nandan |
last post by:
Hi C++ Experts !
I have a little weird requirement.
I have a base class, say B and lots of classes D1 .. Dn publicly
derived from it. Over the course of development the number of derived
classes may increase.
I want that before the execution of one of my particular code, I
should have a list of pointers to all the derived classes, say
std::list<B*ptrList; // contains 'n' elements which are pointers to
D1 .. Dn.
|
by: Gaijinco |
last post by:
I'm trying to do a template class Node.
My node.hpp is:
#ifndef _NODE_HPP_
#define _NODE_HPP_
namespace com { namespace mnya { namespace carlos {
template <typename T>
|
by: nooneinparticular314159 |
last post by:
I'm trying to understand template metaprogramming syntax. It's been
years since I've touched C++, so this may actually be a C++ syntax
issue (although it seems that the language has changed somewhat.)
The following example comes from http://www.codeproject.com/KB/cpp/crc_meta.aspx
template< int i >
class FACTOR{
public:
enum {RESULT = i * FACTOR<I-1>::RESULT};
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
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...
| |