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

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<typename Tstruct X {};
template<typename T, X<T*xstruct Y1{};
template<X<T*x, typename Tstruct Y2{};

Thanks for any help,

Christof
Dec 6 '07 #1
6 1498
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<typename Tstruct X {};
template<typename T, X<T*xstruct Y1{};
template<X<T*x, typename Tstruct Y2{};
Oops, just found the solution:

template<typename Tstruct X {};
template<typename 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<typename Tstruct X {};
template<typename 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<typename Tstruct X {};
template<typename 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<typename Tstruct X {};
>template<typename 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<typename Tstruct X {};
template<typename 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<typename Tstruct X {};
template<typename 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
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...
6
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...
5
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...
3
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...
9
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...
4
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...
3
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
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.