Is it possible using Boost mpl library:-
Assume any class implementing a function "connect" with two arugments of
fixed types
class protocol1
{
connect(T0 & t0, T1 &t1 ){..} //fixed types T0 and T1
};
class protocol2
{
connect(T2 & t0, T3 &t1 ){..} // Fixed types T2 and T3
};
Now a function say "connect_protoc ols" which take two protocols of above
mentioned protocol types
template<typena me P0, typename P1>
connect_protoco ls(P0& p0, P1 & p1)
{..}
What is requires in the body of "connect_protoc ols" function is a checking
meachimism to use correct connect function avilable from one of the class
(protocol1 or protocol2) without genrating the compile time error.
However if no appropriate connect function is avilable (after checking both
the protocol classes) then genrate compile time error.
Is it possible?
Abhsishek 2 3965
Abhishek Saksena wrote: Is it possible using Boost mpl library:-
It's not needed here.
Assume any class implementing a function "connect" with two arugments of fixed types
class protocol1 {
connect(T0 & t0, T1 &t1 ){..} //fixed types T0 and T1 };
class protocol2 {
connect(T2 & t0, T3 &t1 ){..} // Fixed types T2 and T3 };
Now a function say "connect_protoc ols" which take two protocols of above mentioned protocol types
template<typena me P0, typename P1> connect_protoco ls(P0& p0, P1 & p1) {..}
You forgot to state the return type of the function.
What is requires in the body of "connect_protoc ols" function is a checking meachimism to use correct connect function avilable from one of the class (protocol1 or protocol2) without genrating the compile time error.
However if no appropriate connect function is avilable (after checking both the protocol classes) then genrate compile time error.
Is it possible?
It is. Just add factory functions that take the same arguments as your
protocol classes's constructors do:
protocol1 create(T0 & t0, T1 &t1) { return protocol1(t0, t1); }
// the same for protocol2
template<typena me P0, typename P1>
void connect_protoco ls(P0& p0, P1 & p1)
{
create(p0, p1);
}
> What is requires in the body of "connect_protoc ols" function is a checking meachimism to use correct connect function avilable from one of the class (protocol1 or protocol2) without genrating the compile time error.
However if no appropriate connect function is avilable (after checking both the protocol classes) then genrate compile time error.
Is it possible?
Have you tried template specialisation?
I'm not sure if I read correctly what you asked but the following might
be a solution to your problem.
template<class T, class U>
void connect_protoco ls(T &First, T &Second);
template<>
void connect_protoco ls(P0 &First, P1 &Second)
{
// perform connect here
}
template<>
void connect_protoco ls(P2 &First, P3 &Second)
{
// perform connect here
}
This should result in an compile time error unless you fill in the
correct protocols. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: newbiecpp |
last post by:
I have hard time to understand run-time environment. Let assume that I have
a program that has a simple variable alpha. When this variable is
statically allocated, the compiler can use the absolute address of alpha to
access to it. What confuses me is that when the variable is dynamically
allocated, how does the compiler implement it? We know the address of the
variable until run-time. During the compilation, how can we access to the...
|
by: M. Uppal |
last post by:
How do i convert fraction to time in c#. I need to convert 0.25 to time.
Excel does this by using Selection.NumberFormat = "h:mm:ss;@" of the Cell
Format function.
thanks,
M. Uppal
|
by: Shourie |
last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle.
1) MainPage_load
2) User control1_Load
user clicks a dropdown in UC1
_________________________
1) MainPage_Load
2) User Control_1 Load
|
by: Saxman |
last post by:
I need to copy/paste in Excel, but with a delay built in between each
copy/paste operation.
Below is the code which gives me a compile error on the 2nd Sub Delay().
It is a simple copy from sheet 1 to sheets 2,3,4 and 5. Can you see
anything wrong. Help much appreciated.
Thanks
Sub Macro1()
|
by: rob.iverson |
last post by:
We ran into this problem and I can't see why the compilers (Sun One
Studio 8 and g++ 2.95) think it's an error:
-------------------
class A
{
public:
void foo();
| |
by: ABC |
last post by:
How to speed up compile in VS 2005 IDE?
Our solution have many projects, when I only modified a file, I want only to
compile the modified project, not need to compile all projects. It spend
time to compile all projects.
|
by: Trent |
last post by:
Running this I see that on first run, both bubble and selection sort have 9
sort counts while insertion sort has ZERO. With a sorted list, should this
be ZERO for all?
Also bsort and Ssort have the same exact sorting counts also..shouldn't they
differ somewhat?
Source and data file below.
Thanks
|
by: Ioannis Vranos |
last post by:
Perhaps a mechanism can be introduced in the C++0x/1x standard,
something simple like defining a function as:
void somefunc(void) throw()
{
// ...
}
|
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 --
|
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: 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,...
| |
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...
|
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: 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |