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 

Definition of type-dependant and value-dependant expressions

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





PostPosted: Tue Jan 10, 2006 1:03 am    Post subject: Definition of type-dependant and value-dependant expressions Reply with quote



Hello

The definition of dependant expressions in 14.6.2, 14.6.2.2 and 14.6.2.3 is
very convoluted and unintuitive.

Let's first quote the general definition of dependant expressions :


"Inside a template, some constructs have semantics which may differ from one
instantiation to another. Such a construct depends on the template
parameters. In particular, types and expressions may depend on
the type and/or value of template parameters (as determined by the template
arguments) and this determines the context for name lookup for certain
names. Expressions may be type-dependent (on the type of a template
parameter) or value-dependent (on the value of a non-type template
parameter)."


Later, 14.6.2.3/2 states that "sizeof unary-expression" is value-dependant
if "unary-expression" is type-dependant (even if "sizeof unary-expression"
is not type-dependant).

Let's examine an example :

template<typename T>
void f() {

  sizeof T();
}


In this example, T() is clearly type-dependant. Thus, according to
14.6.2.3/2, sizeof T() is value-dependant. But this contradicts completely
the general definition of value-dependant expressions as depending on the
value of a non-type template parameter (there is no non-type template
parameter in this example).

I think it would be clearer to define a type-dependant expression as an
expression whose type depends on a template parameter, and a
value-dependant expression as an expression whose value depends on a
template parameter.

The problem with the current wording is that it first defines a concept
clearly (in 14.6.2/1), and then obfuscates it in the following clauses, so
as to make it completely incomprehensible.



Patrick

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