C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Proposal for a solution of core issue 150

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Kriang Lerdsuwanakij
Guest





PostPosted: Sun Jan 09, 2005 10:09 am    Post subject: Proposal for a solution of core issue 150 Reply with quote



The issue of matching default arguments of a class template
has been discussed in core language issue 150 (Template template
parameters and default arguments), and also the item ES070 in
N1598 document (Allow default arguments for template template
arguments) but there hasn't been a solution so far.

So I propose a solution here based on the variable-length
template parameter list or variadic template idea proposed
elsewhere. It is applied to the template template parameter
syntax.

In the current standard, the following example indicates that
TT is a template template parameter matching a class template
with exactly one template parameter:

template <template void f() {
TT<int> tt;
}

My idea would extend the language to allow new syntax:

template <template void g() {
UU<int> uu;
}

It means that UU matches a class template with at least
one parameter, if there are more than one, all the remaining
must have default arguments.

With this idea, compatibilty with the current standard is
maintained. Moreover, programmers can decide between two behaviors
on a per template basis.

Some examples:

template <class T> class C;
template <class T, class U = int> class D;
template <class T, class U> class E;

template <template void f();
template <template void g();

template <template void h(); // #1
template <template void h(); // #2

template <template void i(); // #3
template <template void i(); // #4

int main() {
f<C>(); // OK
f<D>(); f<E>(); // Error - not match
g<C>(); g<D>(); // OK
g<E>(); // Error - not match
h<C>(); // OK - choose #1
h<D>(); h<E>(); // OK - choose #2
i<C>(); // OK - choose #3
i<D>(); // Error - ambiguous between #3, #4
i<E>(); // OK - choose #4
}

--Kriang Lerdsuwanakij <lerdsuwa (AT) users (DOT) sourceforge.net>

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.