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 

Pre-Redmond Mailing: some thoughts to 1704 & 1706

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





PostPosted: Tue Sep 28, 2004 3:35 pm    Post subject: Pre-Redmond Mailing: some thoughts to 1704 & 1706 Reply with quote



Hi all,


N1706 Opaque Typedefs:

I appreciate this proposal, but I strongly miss a point or at least a
discussion about forwarding typedefs. IMHO forwarded typedefs are an
important motivation for
the introduction of opaque typedefs. Also, how are opaque typedefs
related to ADL (esp. what would happen in the introductory examples of
N1691 Explicit Namespaces, if opaque typedefs were used)?



N1704 Variadic Templates: Exploring the Design Space:

1. Why is it necessary to denote the tuple inside the definiton of the
class/function with its name and the trailing ellipsis? Why isn't the
name sufficent (I think it is)? The examples in 3.1. could be rewritten:

template<typename Head, ... Tail> struct tuple { // #1
Head head;
tuple <Tail> tail;
};

template<typename T, ... Elements>
struct adjacent_find : adjacent_find<Elements> { };

template<... Args> void printf(const char* s, const Args& args);

This would not only cleaning up the syntax a little bit, but also makes
teaching easier (otherwise you have to explain somehow, why in 3.2.
neither 'Elements' nor 'elements' needs the trailing ellipsis, even if
they are tuples).

2. If my first point is somehow accepted, then the next question arises:
why should we stick with the clunky ellipses syntax at all? Why not just
introduce a new keyword 'tuple<>' (or something similar) instead, that
may appear only as a template argument.
tuple<class> and tuple<typename> are interchangeable and denote a tuple
of types (the common use).
tuple<int>, tuple<const char*> etc. denote a tuple of constant integral
expressions evaluated at compile time.
Note, that with this syntax we could mix different tuples in one
template argument list:

template<tuple
class example;

example<int, double, 1, 2, 3>; // legal
example<int, 2, double, 4>; // illegal

Or we can do something like this:

template<tuple
class two_typelists;

3. 3.7 only explains the unpacking of a value from a parameter pack. Why
shouldn't it be possible to unpack a type directly rather than relying
on decltype:

template<tuple
void f(Args args)
{
// Make copy of 2nd argument
Args<1> second = args[1]; //Args<N> denotes the N'th type
}

For tuple<int> this could become the only way to extract a certain
value:

template<tuple
void f ()
{
std::cout << Args<1>;
}

// prints '2':
f<1,2,3>();


4. Maybe the usefulness of tuples wrt default template paramters should
be mentioned:

//a compatible way to use STL containers as template template
parameters:
template< template std_container, class T>
class example {
typedef typename std_container<T>::const_iterator some_type;
//etc.
};



Best regards
Olaf Krzikalla

---
[ 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.