c++ - C++0x, Compiler hooks and hard coded languages features -


I'm curious about some new features of C ++ 0x. Both features require a user-defined class to work specifically and accurately.

I came across, and the top answer was useful, while I do not know if it is completely correct (I'm probably completely misunderstanding, see 3 comments on the first answer) < / Em>. According to the preliminary list, the header defines a type:

  template & lt; Class E & gt; Class initializer_list {public: initializer_list (); Size_t size () const; // Number of Consultants c * start () const; // first element const e * end () const; // last one last element}};  

You can see it in specifications, only Ctrl + F 'class initializer_list' .

= {1,2,3} can be contained in the initializer_list class, to the compiler {} And for some knowledge of the relationship between initializer_list . There is no constructor who receives anything, hence the initializer_list as far as I can tell is a cover which the compiler is actually created which is bound to any object.

This (code: for :) loop, which requires a user-defined type of function (although according to the specs, no code is required for ARA and initial lists But for the initial list, is , so it is a proxy by the user-defined code requirement).

Am I completely misunderstanding how it works? I'm not mistaken in thinking that these new features really relied heavily on the user code. It seems as though the features are half-baked, and instead of making the entire feature in the compiler, it is being half done by the compiler and half of the included part is included. What is the reason for this?

Edit: I typed 'rely heavily on compiler code', and 'do not trust the user code' which I think completely threw my question in the compiler There is no confusion about the new features created, these are things that are built in the compiler that rely on user code.

I'm not mistaken in thinking that these new features really relied heavily on the compiler code

They rely heavily on the compiler. Whether you want to include a header or not, the fact is that in both cases, the syntax today will have a parsing error with Compiler. For (:) is not exactly fit in today's standard, where only is for permission (;;)

It seems As the facilities are semi-cooked, and instead of making the entire feature in the compiler, it is half done by the compiler and includes half the part. What is the reason for this?

Support must be implemented in the compiler, but you must include the system header for this. It can serve two purposes, in the case of the initial list, it brings the type of interface (compiler support to the interface) to the user so that you can see how to use it (think how VA is in C). On the basis of the range (which is just syntactic sugar), you need to radiate the range so that the compiler can show it magic. Note that for the standard (range-declaration: expression) statement defines the equivalent of ([6.5.4] / 1 draft):

  {Auto & amp; __range = (expression); (Auto __begin = std :: range & lt; _RangeT & gt; :: start (__ border), __end = std :: range & lt; _RangeT & gt; :: end (__ border); __begin! = __end; + + __ start) {for-range-declaration = * __ start; Statement}}  

If you want to use it only on the Areas and STL containers, without the implementation of the range concept (not in C ++ 0x meaning) ), But if you want to expand the syntax in user-defined classes (in their own container), then the compiler can easily depend on the existing range template (your possible specialization with). On the basis of a template being defined, the mechanism is equal to the need for a stable interface on the container.

Most other languages ​​have gone in the direction of the need for a regular interface (say container, ...) and runtime polymorphism on it if it was done in C ++, then the entire STL was a major Going through refactoring because STL containers do not share a common base or interface, and they are not ready to use polymorphically.

If any, the current standard underbaked will not be out of time goes out.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -