« first day (984 days earlier)      last day (2488 days later) » 

1:26 AM
@Stargateur what's wrong with the title?
 
if we translate to cpp it's could be "template, object and pointer" XD. And the most difficult part in rust for me is trait and generic and lifetime. And this chapiter look like they combine then together !!!
this make sense but it's hard to follow
 
1:56 AM
@Stargateur Understanding that lifetimes are another type of generic is very powerful
also, rust generics are less powerful than C++ templates
 
probably better like that :p, I love recursive template in C++. But some template are unreadable and I never understand why sometime you need to put typename, template in C++ are very close of black magic.
 
you need to put typename because of specialization
std::vector<T>::value_type could very well be a static const instead of a typedef for some specific T
 
yeah I understand that but why sometime the code don't compile, then you just write typename and magic happen this compile :p
 
2:24 AM
when the compiler sees something like std::vector<T>::value_type (where T is a type parameter), it doesn't know whether value_type is a type or a value; it can't look into the definition of std::vector<T> because some std::vector<whatever_t> could redefine value_type to be the other thing
the compiler has to assume that it must be a value (per the standard), and you add typename to change that decision
when the compiler sees something like std::vector<int>::value_type (where int is a concrete type), it can look at the definition of std::vector<int> because at that point, the compiler knows precisely which definition to use (be it a specialized one or not)
 
oh that is a lot much clear, so the compile has a default behavior that why... thx a lot for the clarification.
I through it try everything until it's compile :p
 
Visual C++ actually lets you get away with omitting typename
I learned that while porting some program written for VC++ to gcc
 
but the standard has introduce this to avoid some ambiguous code I suppose so msvc assume that there is no ambiguous code ?
 
MSVC actually just defers parsing the template, as I understand it
in order to correctly parse C++ code, when you see an identifier, you need to know whether it represents a type name or not
example: a b(c);
is this a function declaration or a variable definition invoking a constructor?
 
impossible to know without context
 
2:33 AM
exactly
 
So MSVC is better to understand context than other compiler ?
 
I guess, but that's not standard-compliant :P
 
like always with microsoft :p
 
to be fair, this behavior might date back to before this aspect was set in the standard
and was preserved for compatibility
 
 
13 hours later…
3:26 PM
Hum... I am always late to the party :(
So, whether MSVC is "better" is rather subjective.
The main advantage of two-phase parsing of templates is that a number of errors can be signalled at the point of definition of the template, rather than at the point it's actually instantiated.
In this sense, MSVC is therefore worse, since it signals errors later :)
 
4:11 PM
ofc every way has his cons ans his pros.
 

« first day (984 days earlier)      last day (2488 days later) »