473,659 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple? sequence issue

Hi,

can anyone tell how to convince the compiler to accept the third
line in the example below? I need this parameter sequence because
I want to define a default argument for T , e.g.:
template<X<T*x, typename T = intstruct Y2{};
template<typena me Tstruct X {};
template<typena me T, X<T*xstruct Y1{};
template<X<T*x, typename Tstruct Y2{};

Thanks for any help,

Christof
Dec 6 '07 #1
6 1508
can anyone tell how to convince the compiler to accept the third
line in the example below? I need this parameter sequence because
I want to define a default argument for T , e.g.:
template<X<T*x, typename T = intstruct Y2{};
template<typena me Tstruct X {};
template<typena me T, X<T*xstruct Y1{};
template<X<T*x, typename Tstruct Y2{};
Oops, just found the solution:

template<typena me Tstruct X {};
template<typena me T, X<T*xstruct Y1{};
class T;
template<X<T*x, typename Tstruct Y2{};

Anyway, thanks,

Christof
Dec 6 '07 #2
Christof Warlich schrieb:
Oops, just found the solution:
Hmm - still having problems: Instantiation does not work:

template<typena me Tstruct X {};
template<typena me T, X<T&xstruct Y1{};
class T;
template<X<T&x, typename Tstruct Y2{};
X<intx;
Y1<int, xy1;
Y2<x, inty2; // this does not compile

Anyone who knows how to do it right?

Many thanks,

Christof
Dec 6 '07 #3
Christof Warlich wrote:
Christof Warlich schrieb:
>Oops, just found the solution:

Hmm - still having problems: Instantiation does not work:

template<typena me Tstruct X {};
template<typena me T, X<T&xstruct Y1{};
class T;
template<X<T&x, typename Tstruct Y2{};
X<intx;
Y1<int, xy1;
Y2<x, inty2; // this does not compile

Anyone who knows how to do it right?
When you try to instantiate Y2 template by giving it 'x' as the first
argument, the compiler has no idea what 'T' is in Y2. It cannot look
ahead to see that you've established that 'T' is 'int' in the second
argument. That's why instantiating 'Y1' works fine, since 'T' is known
at the time when it sees 'x', which then successfully matches to the
object of type X<int>.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 6 '07 #4
>template<typen ame Tstruct X {};
>template<typen ame T, X<T&xstruct Y1{};
class T;
template<X<T&x , typename Tstruct Y2{};
X<intx;
Y1<int, xy1;
Y2<x, inty2; // this does not compile

Anyone who knows how to do it right?

When you try to instantiate Y2 template by giving it 'x' as the first
argument, the compiler has no idea what 'T' is in Y2. It cannot look
ahead to see that you've established that 'T' is 'int' in the second
argument. That's why instantiating 'Y1' works fine, since 'T' is known
at the time when it sees 'x', which then successfully matches to the
object of type X<int>.
And there is nothing like some forward declaration to tell the compiler?
As I said, I need _this_ sequence of template parameters because I'd
like to supply a default argument for T, e.g.:

template<X<T&x, typename T = intstruct Y2{};
Y2<xy2;

Or is there some other way to to provide this default argument?

Christof
Dec 6 '07 #5
Christof Warlich wrote:
>>template<type name Tstruct X {};
template<type name T, X<T&xstruct Y1{};
class T;
template<X<T& x, typename Tstruct Y2{};
X<intx;
Y1<int, xy1;
Y2<x, inty2; // this does not compile

Anyone who knows how to do it right?

When you try to instantiate Y2 template by giving it 'x' as the first
argument, the compiler has no idea what 'T' is in Y2. It cannot look
ahead to see that you've established that 'T' is 'int' in the second
argument. That's why instantiating 'Y1' works fine, since 'T' is
known at the time when it sees 'x', which then successfully matches
to the object of type X<int>.

And there is nothing like some forward declaration to tell the
compiler? As I said, I need _this_ sequence of template parameters
because I'd like to supply a default argument for T, e.g.:

template<X<T&x, typename T = intstruct Y2{};
Y2<xy2;

Or is there some other way to to provide this default argument?
You will likely have to define a different template for that and if
you need to share functionality, derive it from the Y2:

template<X<int& xstruct Y2int : Y2<int,X<int>&{ };

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 6 '07 #6
>>>template<typ ename Tstruct X {};
template<typ ename T, X<T&xstruct Y1{};
class T;
template<X<T &x, typename Tstruct Y2{};
X<intx;
Y1<int, xy1;
Y2<x, inty2; // this does not compile

Anyone who knows how to do it right?
When you try to instantiate Y2 template by giving it 'x' as the first
argument, the compiler has no idea what 'T' is in Y2. It cannot look
ahead to see that you've established that 'T' is 'int' in the second
argument. That's why instantiating 'Y1' works fine, since 'T' is
known at the time when it sees 'x', which then successfully matches
to the object of type X<int>.
And there is nothing like some forward declaration to tell the
compiler? As I said, I need _this_ sequence of template parameters
because I'd like to supply a default argument for T, e.g.:

template<X<T&x , typename T = intstruct Y2{};
Y2<xy2;

Or is there some other way to to provide this default argument?

You will likely have to define a different template for that and if
you need to share functionality, derive it from the Y2:

template<X<int& xstruct Y2int : Y2<int,X<int>&{ };

V
.... which doesen't seem to make things look better than abandoning the
idea of supplying a default ....
Anyhow, thanks a lot for your help, at least I know now that there is
no simple solution that I have missed. And fortunately, my life doesn't
depend on finding one ;-).

Christof
Dec 6 '07 #7

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

Similar topics

0
7109
by: mjcsfo | last post by:
I can't seem to find a reference nor any helpful threads on this topic. I've gotten the following error in two circumstances: 1. A complex type has nested within it another complex type, in the "Russian doll" style of schema design, where the nested type is local and anonymous (not a separate global type). 2. A complex type has nested within it a simple type which is derived through restriction with at least one facet, again nested,...
6
4956
by: hoover_richard | last post by:
I am a newbie to C++ and I need help with a simple program I am trying to write. My program is designed to print all of the odd integers contained in an array and output the sum of the odd integers. My code is listed below, but the problem is that my output of sum is wrong. For example, I am using 1347830 for my integers and the program outputs 373 and after adding 373 you should get 13 for the total, but that doesn't happen. Any help...
5
3247
by: Eric E | last post by:
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from the sequence and write to the field. Sometimes, however, these sequence numbers will be discarded (after a transaction is complete), and thus available for use. During the transaction, however, any drawn numbers need to be unavailable. I would...
3
4717
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema to not be sequenced. (PERL hashes do not retain order information) First, the w3 specs don't mention the sequence in any detail - its just there in the examples, which makes me wonder if removing the sequence tag is even supportable. Second,...
9
3952
by: c_beginner | last post by:
Dear group, I want to implement a solution to the following link: http://acmicpc-live-archive.uva.es/nuevoportal/data/p2006.pdf As a beginning I am trying to implement this little sample program which will delete the repeated strings in two set of strings.
4
4381
by: Shawnk | last post by:
This post is intended to verify that true value semantics DO NOT EXIST for the Enum class (relative to boolean operations). If this is true then (thus and therefore) you can not design state machines in C# where the machine can use the enumerated 'state' to execute (thus the term 'machine' as in 'state machine') the machine operations as this requires boolean operations to be performed on the state. .....
3
3097
by: Eric Lilja | last post by:
Hello, this is an xml-file with a nested DTD. It validates, test-1- with-dtd.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE persons > <persons> <person name="Eric Lilja" /> </persons>
2
2037
by: astrogirl77 | last post by:
Hi, I'm new to Python and am hoping to find help with coding a Python script, applet. I code in an old version of Visual Basic 4.0, I have a simple app that is about 3 and a half pages of code long it does some relatively simple math additions and subtractions The problem I have is that some numbers get to be very large integers and VB automatically converts this to scientifc notation, what I need is to have all numbers added and...
1
2066
by: astrogirl77 | last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's. I code in an old version of Visual Basic 4.0, I have a simple app that is about 3 and a half pages of code long it does some relatively simple math additions and subtractions The problem I have is that some numbers get to be very large integers and VB automatically converts this to scientifc notation, what I need is...
0
8748
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
8531
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
8628
tracyyun
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...
0
7359
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
5650
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();...
0
4175
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
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.