473,385 Members | 2,003 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,385 software developers and data experts.

learning policy classes

er
hi,

i'm trying to understand A) policy classes and see if they meet my
needs. the book "C++ templates" has something similar called B)
"bridge pattern implemented with templates". would it be fair to
characterize them like this?

template<class Impl>//Impl has to have void op();
class A{//bridge pattern
Impl impl;
public:
void op(){impl.op();};
}
template<class Impl>
class B: public Impl{};//Impl used as a policy

what i'm really leading to is the issue of having more than one
template parameter, say
template<class Impl1,class Impl2class A;
template<class Impl1,class Impl2class B:public Impl1,Impl2{};
and either of Impl1 and Impl2 has a constructor which takes arbitrary
arguments.

i think that's not a problem for A (?):
A<Impl1,Impl2>::A(const Impl1& i1,const Impl2 i2):impl1(i1),impl2(i2)
{};

i guess i do the same for B ? or is this reasonable?
template<class In1, class Impl1,class In2, class Impl2//must satisfy
Impli::Impli(Ini), i=1,2
class B: public Impl1,public Impl2{};
B<In1,Impl1,In2,Impl2>::B:Impl1(In1),Impl2(In2){} ;

this means that for each Impl1 with constructor Impl1::Impl1(Args...),
i have 1) to create a class In1::In1(Args...) and overload as
Impl1::Impl1(In1). i haven't seen any examples like this so i'm
wondering if policies are suitable in this context. if they are, is
there a way that the host (B) can deduce In1, In2, rather than make
them explicit?

Oct 22 '07 #1
0 1414

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

Similar topics

9
by: Martin Vorbrodt | last post by:
I'm designing a Matrix class of 4x4 matrices used in computer graphics. Both OpenGL and Direct3D can take a pointer to array of 16 floats which represent the values in the matrix. OGL takes it in...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
5
by: Amai | last post by:
I'm ineterested in learning ASP.NET, in conjunction with both C# and VB.NET. However, i don't really know where to start. Are there classes available at local colleges, or do i have to go...
4
by: aaragon | last post by:
Hello everyone. I'm reading Andrei's Alexandrescu's book on Modern C++ Design and I decided to implemente in my research code the use of policy classes. My objective is to abstract the storage of...
11
by: aaragon | last post by:
Hi everyone. I'm trying to write a class with policy based design (Alexandrescu's Modern C++ Design). I'm not a programmer but an engineer so this is kind of hard for me. Through the use of...
1
by: whosesocks | last post by:
I discovered that many of my very busy colleagues are having an extremely difficult time pulling themselves away to take vital training when it requires being away for consecutive days. I just...
3
by: Stephen Torri | last post by:
Below is a class that is suppose to represent a segment of memory or a contents of a binary image (e.g. ELF executable). I have started to read Modern C++ Design and thought the best way to ensure...
3
by: DerrickH | last post by:
I have a template class with three policies: PolicyA, PolicyB, and PolicyC. The design dilemma I am having is that B and C depend upon A, but I would like my Host class to derive from all three. In...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...

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.