Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

C9 Lectures: Stephan T Lavavej - Advanced STL, 2 of n

Download

Right click “Save as…”

As promised, the great Stephan T. Lavavej is back! Smiley  Tens of thousands of you have watched STL's (those are his initials, so that's what we call him) introductory series on the STL, or Standard Template Library. If you haven't, you should. This series, Advanced STL, covers the gory details of the STL's implementation -> you will therefore need to be versed in the basics of STL, competent in C++ (of course), and be able to pay attention! Stephan is a great teacher and we are so happy to have him on Channel 9—the only place you'll find this level of technical detail regarding the internals of the STL. There are no books. There are no websites. This is Stephan taking us into what is uncharted territory for most, even those with a more advanced STL skill set.

In the second part of this n-part series, Stephan digs into implementation strategies for various STL algorithms and opens the hood to look at some of the machinery inside the STL employing the goodness of template meta-programming and type traits. You'll also learn about some C++0x features that are used inside STL.

As you continue to learn about the beauty and the weirdness inside the STL, you should take Stephan's wisdom to heart and see if you can implement some of the patterns he shares with you in your own code. And you should, of course, take his advice about what NOT to do in your native compositions.

Tune in. Enjoy. Learn.

[Advanced STL]

Part 1 (shared_ptr - type erasure)

Part 2 (equal()/copy() - algorithm optimizations)

Part 3 (_ITERATOR_DEBUG_LEVEL, #pragma detect_mismatch, and /d1reportSingleClassLayout)

Part 4 (rvalue references v2.1 and associative container mischief)

Part 5 (deduplicator, using Boost.Bimap/Filesystem/ScopeExit) - see Stephan's deduplicate.cpp

Part 6 (container pretty printer) - see Stephan's pretty_printer.cpp

Tags:

Follow the Discussion

  • felix9felix9 the cat that walked by itself

    wow, live debugging of VC11 ! Cool

  • @44:22 Casting to void* would be unwise, because you cannot do pointer arithmetic on void pointers Wink

  • LiamLiam

    Would someone please explain why Microsoft insist on calling the C++ Standard Library the STL? If it is standard then surely every implementation would call it so and also the standard committee. 
    #pet C++ hate number 1024

  • CharlesCharles Welcome Change

    Would someone please explain why Microsoft insist on calling the C++ Standard Library the STL?

     

    Sure. In fact, we (Microsoft or anybody else for that matter....) don't do this... I'm not sure how you've arrived at this conclusion. STL = Standard Template Library.  These libraries share many things in common, but they are not the same things.


    C

  • LiamLiam

    Sure. In fact, we (Microsoft or anybody else for that matter....) don't do this... I'm not sure how you've arrived at this conclusion. STL = Standard Template Library.  These libraries share many things in common, but they are not the same things.
     
    Charles,
    I am sorry, maybe it is me being dumb. The videos are about "STL" which is what exactly? Lets take std::copy for example that is from the C++ Standard Library not something called the Standard Template Library. Where does the standard in STL come from and are these videos really referring to the SGI implementation called STL? I do not recall the standard making any mention of a STL.

  • CharlesCharles Welcome Change

    @Liam:  You are not being dumb.... These videos are about the Dinkumware implementation of STL (So, the STL implementation that ships with VC++). There are many different implementations of the STL, all based on the language standard.

     

    C

  • felix9felix9 the cat that walked by itself

    according to MSDN: http://msdn.microsoft.com/en-us/library/f1dtts6s.aspx

    ...... Standard Template Library, a subset of the Standard C++ Library.

    and, http://msdn.microsoft.com/en-us/library/ct1as7hw.aspx

    The C++ library headers have two broader subdivisions:

    iostreams conventions.

    Standard Template Library conventions.

     and STL is a sub-topic under C++ Standard Library in the documentation tree: http://msdn.microsoft.com/en-us/library/c191tb28.aspx

    and, according to Dinkumware: http://www.dinkumware.com/manuals/default.aspx#Standard%20C++%20Library

    The Standard C++ library consists of 51 headers. Of these, 16 constitute the Standard Template Library, or STL.

  • LiamLiam

    Ok I do not want to be seem as trolling here :)
    So it is dinkumwares fault that the Algorithm, Container et al libraries are being called STL?

  • felix9felix9 the cat that walked by itself

    I think its a very widely used name to refer this part of C++ Standard Library that incorporated or 'absorbed' from the original STL library.

    one more example: in the book "The C++ Standard Library: a Tutorial and Reference" by Nicolai M. Josuttis, there is a chapter called "The Standard Template Library", it starts with:

    The heart of the C++ standard library, the part that influenced it overall architecture, is the Standard Template Library (STL).

    one more: the C++ Reference site: http://www.cplusplus.com/reference/

    (It) can be divided into::

    C Library
    C++ Standard Library: Miscellaneous libraries
    C++ Standard Library: Standard Template Library (STL)
    C++ Standard Library: Input/Output Stream Library

  • felix9felix9 the cat that walked by itself

    and in the book C++ Cookbook, it says (p213) :

    The part of the library that comprises the containers is often referred to as the Standard Template Library, or STL, becauses this is what it was called before it was included in the C++ Standard.

  • new2STLnew2STL xkcd.com

    Hey Charles, wich version of video you use on smoothstream? even when i go fullscreen it looks aliased, like the Medium Quality WMV (I have a 10Mbps line, but for international link It sometimes drop to 1Mbps, depending the destination server).

  • LiamLiam

    @felix9 Thank you for doing some research but I think you will find the only piece of literature worth quoting about C++ is the standard itself. I did acknowledge the origins of the name "STL" in my second post and queried if we were talking about the same dead implementation and it seems we are.

  • felix9felix9 the cat that walked by itself

    @felix9 Thank you for doing some research but I think you will find the only piece of literature worth quoting about C++ is the standard itself. I did acknowledge the origins of the name "STL" in my second post and queried if we were talking about the same dead implementation and it seems we are.

    if read carefully you can see that all of my quotes are talking about the part of the actual standard library, the 'dead implementation' is only mentioned when people want to explain 'why' they are using this term this way.

    I dont think the standard itself is 'the only piece of literature worth quoting', surely you are getting way too formal here. this term is so widely used in the industry and academia, everybody understand it and take it naturally, if you want to talk that way then good for you, but we are living people and we dont need to always speak the 'iso standard' language.

  • @felix9 Thank you for doing some research but I think you will find the only piece of literature worth quoting about C++ is the standard itself. I did acknowledge the origins of the name "STL" in my second post and queried if we were talking about the same dead implementation and it seems we are.

    Felix9 is correct.

    Here's another example: Stroustrup mentions in his book: "Every algorithm works with every container without the use of conversions. This framework, conventionally called the STL [Stepanov,1994], is extensible in the sense that users can easily provide containers and algorithms in addtion to the ones provided as part of the standard and have these work directly with the standard containers and algorithms" (section 3.10 from The C++ Programming Language 3rd ed.). In sections 16.2 and 16.2.3, for example, he mentions the algorithms and containers portion of the standard library are often called the STL or STL framework.

     

    I hope this has helped clear up any confusion.

  • CharlesCharles Welcome Change

    OK. Now that we understand the distinction between STL and the C++ Standard..... Keep this focused on the content in the video, please. Smiley

    C

  • LiamLiam

    @Charles:
    Yes, now that we know the C++ Standard Library or its collection of libraries are not called STL can we stop calling it so? I have had this conversation with many people and noone seems to be able to give me a good explaination why they call it so, other than "well he called it that". I also wonder when STL became the Standard Template Library.
    "In 1992, when the project was formed, there were eight people in it. Gradually the group diminished, eventually becoming two people, me and Meng Lee. While Meng was new to the area---she was doing compilers for most of her professional life---she accepted the overall vision of generic programming research, and believed that it could lead to changing software development at the point when very few people shared this belief. I do not think that I would be able to build STL without her help. (After all, STL stands for Stepanov and Lee...) "
    http://www.sgi.com/tech/stl/drdobbs-interview.html

  • felix9felix9 the cat that walked by itself

    no we are not going to stop calling it so, for the sole purpose of irritating those people who doesnt like it, any problem with that ?

  • @Charles:
    Yes, now that we know the C++ Standard Library or its collection of libraries are not called STL can we stop calling it so? I have had this conversation with many people and noone seems to be able to give me a good explaination why they call it so, other than "well he called it that". I also wonder when STL became the Standard Template Library.
    "In 1992, when the project was formed, there were eight people in it. Gradually the group diminished, eventually becoming two people, me and Meng Lee. While Meng was new to the area---she was doing compilers for most of her professional life---she accepted the overall vision of generic programming research, and believed that it could lead to changing software development at the point when very few people shared this belief. I do not think that I would be able to build STL without her help. (After all, STL stands for Stepanov and Lee...) "
    http://www.sgi.com/tech/stl/drdobbs-interview.html

    Well, regardless of whether you agree or disagree with the usage of STL, Charles is right. We should return the focus on the content of the video.

  • CharlesCharles Welcome Change

    @dbug: Thanks. There is excellent information in this lecture. Please watch and listen. Then ask questions related to what STL (Stephan Smiley ) is talking about.


    C

  • STLSTL

    felix9> wow, live debugging of VC11 !

    Actually, VC10 RTM. I refer to VC11 frequently because to me it's the present and VC10 is the past.

    NotFredSafe> Casting to void* would be unwise, because you cannot do pointer arithmetic on void pointers

    Look carefully at VC10's <xutility>:

    template<class _InIt,
        class _OutIt> inline
        _OutIt _Copy_impl(_InIt _First, _InIt _Last,
            _OutIt _Dest, _Scalar_ptr_iterator_tag)
        {    // copy [_First, _Last) to [_Dest, ...), pointers to scalars
        ptrdiff_t _Count = _Last - _First;
        _CSTD memmove(&*_Dest, &*_First,
            _Count * sizeof (*_First));
        return (_Dest + _Count);
        }

    My point is that pointer arithmetic is completely unnecessary here. Instead of _Count, we could calculate _Bytes. I slightly misspoke - I should have said char * instead of void *.

    Liam: Along with many other people, I use "STL" to refer to "the subset of the C++ Standard Library that was derived from, or was designed in imitation of, Stepanov's original design". Therefore, vector and sort() are clearly parts of the STL. So are copy_if() and shared_ptr, even though they're new to C++0x. std::string is a borderline case. iostreams are clearly *not* part of the STL - they follow radically different design principles.

    There are many useful terms that the Standard doesn't mention. Did you know that SFINAE (Substitution Failure Is Not An Error) is never mentioned in the Standard, despite being covered by several important paragraphs? And this is a term that the Standardization Committee's members use freely among themselves.

    Some people, through metonymy, refer to the whole C++ Standard Library as the STL, but I consider such usage to be misleading. I've probably been lazy and guilty of it a few times, but I try not to be.

    If you don't want to say "STL", you don't have to, but the term isn't confusing so there's no point in complaining when other people use it.

  • bobbob

    The _Advance function for bidirectional_iterator_tag has this code:
      for (; 0 < _Off; --_Off)    ++_Where;  for (; _Off < 0; ++_Off)    --_Where;
    That's a little disappointing considering that this way saves a branch when the parameter is positive, which should be the common case:
      if (_Off > 0) {    do {      ++_Where;      --_Off;    } while (_Offset > 0);  } else {    for (; _Off < 0; ++_Off)       --_Where;  }
    Another branch could be saved by an overload that takes an unsigned offset, since in that case the parameter does not have to be checked to see if it is negative. Though perhaps having an unsigned overload would violate the standard.
    The only saving grace I can come up with is if the compiler can always perform these two optimizations on its own.

  • LiamLiam

    @STD
    The problem is that these subsections already have names given by the standard yet people seem to ignore this, where does it stop? You stated that you feel std::cup_cakes is part of JimJams yet it comes from Boost, why not refer to it as the Boost Library; hell why stop there why not rename the language. I think Flapjack is as good as any other name.
    I personally find it lazy and uninformed that some people wrongly refer to sections of the Standard Library as PANCAKES, however what I find worse than this is somebody who is informed and still calls it by an incorrect name. Lets go the whole hog and refer to it as Stepanov and Lee.
    At this point I realise that I am not going to change anyones mind here on this topic and would just like to say I do enjoy the videos Paul.
    Yours, the Earth is flat
    Galileo Galilei

  • Discussing terminology is often futile. For example, most C++ programmers say that "a pointer is a variable that stores an address", which is completely wrong. Should I go around correcting these people all the time? No. It is common vocabulary that you simply cannot eradicate anymore. As long as everybody understands what you're talking about, there's no problem. We all know that, at least in the context of these videos, STL means "the part of the standard library that is based upon the ideas of containers, algorithms and iterators".

    (In case you're wondering, despite its name, the unary prefix operator & does not yield an address, but a pointer. The correct way to say it would be "a pointer variable is a variable that stores a pointer", which is quite obvious, so you won't hear it uttered very often.)

  • SteveSteve

    "For example, most C++ programmers say that "a pointer is a variable that stores an address", which is completely wrong. Should I go around correcting these people all the time? No"
    "The result of the unary & operator is a pointer to its operand. The operand shall be an lvalue or a qualified- id. In the first case, if the type of the expression is “T,” the type of the result is “pointer to T.” In particular, the address of an object of type “cv T” is “pointer to cv T,” with the same cv-qualifiers." 
    "The address of an object of incomplete type can be taken, but if the complete type of that object is a class type that declares operator&() as a member function, then the behavior is undefined (and no diagnostic is required).The operand of & shall not be a bit-field."

  • C64C64

    Are you sure that the optimized memcmp() version is called for std::equal in release builds?

     

    With VS2008 SP1, I tried with a simple modification to <xutility> header, adding a printf() for logging purposes before ::memcmp() calls, and the printf() message is *not* printed in release builds with _SECURE_SCL=0.

     

    Thanks.

     

  • MarcMarc

    @Liam
    Your last post rather takes the argument out from under you, don't you think? You posit that there should be a slippery slope where we use all manner of different, arbitrary names for different parts of the C++ Standard Library (JimJams, Flapjacks, Pancakes, etc), and yet that simply hasn't happened.

    In fact, the names have been rather stable, don't you think? I mean, isn't that your real complaint? A library was created, then adopted by the standards committee and the general populous kept using the same name for it. Oh the horror!

    We definitely need to change the name of every library once it gets popular or standardized, otherwise people will keep trolling awesome videos that peeking under the covers of these libraries to complain that the library today is not the same as the library 15 years ago.

    (Hint, in the real world, things can have many names, and people deal with it just fine.)

  • IvanIvan

    Very cool video, not just because we have similar wallpapers. :D
    Just one small question, although this is more a optimization question, and not STL question. Have you ever considered using instruction level parralelism to improve performance on random access structures. For example if you are doing somthing like sum+=v[i]you could start from the start and start from the middle at the same time. Because CPUs can handle more than one instruction at the time it could be faster for some operations. Although you can have some "problems"because you must account for odd(not even) sized structures. And you would have to for example have sum1, sum 2, and sum would be sum1+sum2.
    Don't get me wrong, I know that there is no sum in STL, it was just an example. If user writes a simple lambda that does sumation is there any chance that you can tell the compiler that that vector is huge(aka please if you can optimize this on vectors). If it isn't clear what I'm saying:
    // STL even.cpp : Defines the entry point for the console application.//#include #include #include #include #include using namespace std;int main(){    vector v (8*1024*1024+1);    iota(v.begin(),v.end(),0);    long long sum=0;    clock_t start, finish;    start = clock();    //*    for_each(v.begin(),v.end(),[&sum] (int& x){    sum+=x;    });    //*/    /*         long long sum1=0;    long long sum2=0;    auto half=v.size()/2;    auto j=half;    for (auto i=0; iI can notice big diff in execution time(i compiled 2 times - first time with lambda part, second time with the sum1, sum2 part, and renamed the .exe):
    ...\nx01\Documents\Visual Studio 2010\Projects\STL even\Release>"STL even_nomal.exe"3518437628313629
    //nomal should be normal -this is the lambda version...\nx01\Documents\Visual Studio 2010\Projects\STL even\Release>"STL even_optim.exe"3518437628313618
    //this is the sum1, sum2 version
    P.S. sorry for my bad English and for my bad cpp. :D
     
     
     
     

  • IvanIvan

    @Ivan:
    my bad, there is a bug in the code(sums are different) :cry: , :blush:, but I hope you get the idea.

  • STLSTL

    bob> this way saves a branch when the parameter is positive, which should be the common case

    That's true, but your implementation generates more code (I measured 42 bytes for our implementation and 46 bytes for yours), so it's not an unconditional win.

    (Edited due to a copy-and-paste error - d'oh!)

    My profiling indicates that your implementation is 3.4% faster in the best possible case of an extremely tight loop, and advancing by just 1.

    C:\Temp>type meow.cpp
    struct Node {
        Node * Next;
        Node * Prev;
        int Myval;
    };
    
    struct BidIt {
        void operator++() {
            Ptr = Ptr->Next;
        }
    
        void operator--() {
            Ptr = Ptr->Prev;
        }
    
        Node * Ptr;
    };
    
    typedef int Diff;
    
    void stl_bidi_advance(BidIt& Where, Diff Off) {
        for (; 0 < Off; --Off) {
            ++Where;
        }
    
        for (; Off < 0; ++Off) {
            --Where;
        }
    }
    
    void bob_bidi_advance(BidIt& Where, Diff Off) {
        if (0 < Off) {
            do {
                ++Where;
                --Off;
            } while (0 < Off);
        } else {
            for (; Off < 0; ++Off) {
                --Where;
            }
        }
    }
    
    #include <iostream>
    #include <ostream>
    #include <windows.h>
    using namespace std;
    
    long long counter() {
        LARGE_INTEGER li;
        QueryPerformanceCounter(&li);
        return li.QuadPart;
    }
    
    long long frequency() {
        LARGE_INTEGER li;
        QueryPerformanceFrequency(&li);
        return li.QuadPart;
    }
    
    void print_time(const long long start, const long long finish, const char * const s) {
        cout << s << ": " << (finish - start) * 1000.0 / frequency() << " ms" << endl;
    }
    
    const int N = 100000000;
    
    void test_stl(Node& two, int& dummy) {
        for (int i = 0; i < N; ++i) {
            BidIt iter = { &two };
    
            stl_bidi_advance(iter, i % 1000000 == 0 ? -1 : 1);
    
            dummy += iter.Ptr->Myval;
        }
    }
    
    void test_bob(Node& two, int& dummy) {
        for (int i = 0; i < N; ++i) {
            BidIt iter = { &two };
    
            bob_bidi_advance(iter, i % 1000000 == 0 ? -1 : 1);
    
            dummy += iter.Ptr->Myval;
        }
    }
    
    int main() {
        Node one;
        Node two;
        Node three;
    
        one.Next = &two;
        one.Prev = nullptr;
        one.Myval = 11;
    
        two.Next = &three;
        two.Prev = &one;
        two.Myval = 22;
    
        three.Next = nullptr;
        three.Prev = &two;
        three.Myval = 33;
    
        int dummy = 0;
    
        for (int k = 0; k < 5; ++k) {
            long long start = counter();
            test_stl(two, dummy);
            long long finish = counter();
    
            print_time(start, finish, "STL");
    
            start = counter();
            test_bob(two, dummy);
            finish = counter();
    
            print_time(start, finish, "bob");
        }
    
        cout << "dummy: " << dummy << endl;
    }
    
    C:\Temp>cl /EHsc /nologo /W4 /MT /O2 /GL meow.cpp
    meow.cpp
    Generating code
    Finished generating code
    
    C:\Temp>meow
    STL: 379.114 ms
    bob: 366.741 ms
    STL: 378.975 ms
    bob: 366.848 ms
    STL: 379.239 ms
    bob: 366.663 ms
    STL: 379.446 ms
    bob: 366.767 ms
    STL: 378.994 ms
    bob: 366.64 ms
    dummy: -1359760368

    Interestingly, as I increase the distance, the performance gap widens before closing again (as expected): 3.4% for 1, 5.3% for 2, 5.6% for 3, 3.5% for 4, 2.5% for 5.

    That's still pretty small (and it's only for bidi, not weaker or stronger iterators), but I'll think about it.

    C64> Are you sure that the optimized memcmp() version is called for std::equal in release builds?

    Yes (for char, signed char, and unsigned char, as I mentioned). I just verified that by debugging VC10 RTM.

    We rewrote the STL between VC9 and VC10 - I'd have to set up a VM to see what VC9 did.

    Ivan> Have you ever considered using instruction level parralelism to improve performance on random access structures.

    It's hard to do that sort of thing unobservably - i.e. without damaging correctness or performance in some scenarios. In the STL, we implement library optimizations only when they won't damage correctness anywhere, and they must be a strict performance improvement, or have minor negative effects in rare scenarios.

    This sort of thing is better done by the user, possibly with a full-fledged parallel_for_each() (if you can break up the computation like that, you may as well use multiple cores).

    Ivan> Don't get me wrong, I know that there is no sum in STL

    Actually, there is: accumulate() in <numeric>. (It's one of the few algorithms hiding in <numeric> instead of <algorithm>.)

  • bobbob

    @STL:
    Interesting. I wouldn't be surprised if the % operation you use for the test is actually responsible for a significant part of the runtime. It should be less common for the argument to advance to be negative, and I wonder if MSVC++ is smart enough to usually remove the negative branch when it can't be taken statically. In that case your way may actually be better if the compiler is smart enough to remove the negative branch, but not smart enough to combine the first if and the do {...} while condition back into a single branch instruction. Since then you get the same number of dynamic branches but the code is larger. If you use an unsigned type for the argument (so then the compiler really really should be able to eliminate the negative loop) and the two implementations then behave identically in terms of size and speed then this probably isn't a concern and otherwise probably it is a concern.
    Thanks for the great video by the way.

  • , new2STL wrote

    Hey Charles, wich version of video you use on smoothstream? even when i go fullscreen it looks aliased, like the Medium Quality WMV (I have a 10Mbps line, but for international link It sometimes drop to 1Mbps, depending the destination server).

    sorry for going OT, but I'm also seeing very poor quality in full-screen or zoomed browser. I have a fast connection, and I was able to stream the 'High Quality WMV' without dropping frames. It would be great if you could enable smooth-streaming for some of the higher bitrate streams.

  • new2STLnew2STL xkcd.com

    Off-Topic: I like test my connection from time to time with the IIS Smooth Stream's test HD movie (Big Buck Bunny), it works perfect for all stream bands, what is awesome Big Smile

    On-Topic: Another great video, but I think this time have not much to comment, besides the partition code comments between @STL and @Bob, everything else is a nice use the type_traits and compiler branch on function overloads (sorry i forgot the term @STL use Blushing ). The only draw is that for those not yet fully accustomed to the way in which variables are noted, is a bit confusing to track then on the source code. I'm sure thare are a add-in for VS that make a nice visual track on function call, that can help on the misson for starters (like me)

    Instead of people diverge on the roots of worth the terns "Standard Templare Library" why not suggest next topics, like we did on previous video Wink I still waiting anything about Allocators (yea for that off-topic SSE discussion Tongue Out)

    I remember @STL says one of the few things that disgust him is when people is not paying attention Perplexed

  • petkepetke

    Good video. Interesting optimization of std::copy. I'm a bit jealous you get to do metaprogramming every day at your job. Its good though you did not edit out that part where you found that performance bug in the optimization of std::equal.. Sometimes its the bugs that are the most valuable to learning.
    One suggestion though for the IDE guys at MS.. as sseen in this video, when debugging and stepping into a function you often have to step into and out of a bunch of argument calls that you are not interested in. That gets a bit frustrating after a while.. especially if you then accidentally step out of the function you are interested in, and have to start all over again. It would be nice to be able to highlight the part of a statement that one is interested in, right click, and get to select "step into". Then you would not have to step into all those other parts of a   statement you are not interested in. Thats cant be to hard too hard to implement, as you got all the logic there, all we need is a button.
    Thanks.
     

  • IvanIvan

    @STL:
    OK, my bad... but can you answer the question... I understand that optimizing sum in that way can be tricky if you have large negative and positive numbers ...sum1+ sum2 can give result 1729 while simple sum can overflow... but for example find() could start from the beggining and from the middle. Again I don't know how many comparisons can a  CPU make in parallel, so it might be a failure.  So again here is my baaaad code(checking if size is even or not is really hard (for my skill level), and I had little time to do this, but the point of this code is to ilustrate what i mean, not to be legit :D)
     
    #include #include #include #include #include using namespace std;vector::iterator my_find(vector::iterator first, vector::iterator last, int element){    auto middle=first;    auto dist=distance( first, last);    advance(middle, dist/2);    while (middle v (40*1000*1000+1);    iota(v.begin(),v.end(),0);        clock_t start, finish;    int value=15*1000*1000;    start = clock();    //*    auto it=std::find(v.begin(),v.end(),value);    //cout<<*it< 
    P.S. I know that formatting will be lost, but you can c/p in something and auto format it.
    P.P.S because of advance() something like this can only work on RA it. And remember this code is broken, it's just to show what I mean.

  • STLSTL

    bob> Thanks for the great video by the way.

    I'm glad you like it.

    petke> I'm a bit jealous you get to do metaprogramming every day at your job.

    Heh heh. It's hard to explain my job to non-programmers, though. "I write lots of angle brackets. No, not like HTML."

    petke> Its good though you did not edit out that part where you found that performance bug in the optimization of std::equal.. Sometimes its the bugs that are the most valuable to learning.

    Yes, I thought that'd be interesting. The only time I've ever asked them to edit anything out is when I accidentally created two meow.cpp files, got stuck in the wrong one, and was confused why my source wasn't compiling when it was clearly correct. (Ordinarily I don't use the IDE, so the most trouble I can get into is opening two editors for the same file.)

    Ivan> but can you answer the question...

    I did. It's hard to do what you're describing in such a way that it *never* harms users. As the STL is a general purpose library for pure computation, it gets used by zillions of people in zillions of ways. This restricts what optimizations we can perform.

  • CharlesCharles Welcome Change

    @piersh/new2STL:  I'm not sure what's going on here. The idea behind Smooth Streaming is that we will deliver the highest quality stream that the SL player detects you're capable of handling given local network conditions.

     

    I recommend that you simply watch the high bitrate WMV or MP4 if that works better for you. Since you both are on high speed networks, why not? In the meantime, I will ask the folks who have the answers regarding SS and high qulaity streaming (again, it's supposed to just work once your high speed network is detected....).


    C

  • IvanIvan

    @STL:
    cool tnx, for the answer.
    my implementation was wrong on so many levels. Including the fact that second it starsts from the middle, and that is a wrong, because fucntion should return the FIRST occurence, not ANY. So I can say now that I'm unable to outoptimize your implementation. :D Good job. :D
     
     
     
     

  • new2STLnew2STL

    (Off-topic) @Charles: Hi Charles, I decided to make a test: Wait some days and played the SmoothStream at a early morning. Result: The SmoothStream worked at hi-rez when I go to fullscreen. The 'problem' is the huge success of @STL videos that are making the bandwidth drop shared by all of his fans on the first days of launch :D

  • @STL: Something I would like to see in future Advanced STL lectures would be a discussion of allocator trickiness, especially if you do any EBO (Empty Base Optimization) trickery.  You may also want to discuss any special list::splice nastiness.

    One other thing I am curious about... do the internal functions that take iterator tags get inlined to the point that no stack space is consumed by the tag instance?  Basically, is that function call completely free, or does it cost you 1 byte on the stack in various places?

  • @STL: Outstanding video!

    Suggestion:  Sometimes it helps to look at the Release-mode assembly output (i.e. assembly output after optimizations) to convince a programmer that template meta-programming is actually doing something useful.  I know that this has helped me.  Using /FAs (or [in the IDE] selecting "Assembly With Source Code (/FAs)" from the "Assembler Output" drop-down box in Configuration Properties \ C/C++ \ Output Files from a project's Property page), allows a programmer to see the fruits of their template-meta-programming labor.

    If certain instructions in the assembly output are unfamiliar (like they are for me), then looking at the instruction set reference in combination with the assembly output can also be helpful:
    http://www.intel.com/products/processor/manuals/

    Specifically, these pdfs:
    http://www.intel.com/Assets/PDF/manual/253666.pdf
    http://www.intel.com/Assets/PDF/manual/253667.pdf

    Hope This Helps,
    Joshua Burkholder

    P.S. - For g++ to output assembly, the following command line can be used (assuming a file named main.cpp):

    g++ -S -fverbose-asm main.cpp -std=c++0x -march=native -O3 -Wall -Wextra -Werror

  • Awesome video, as usual!

    A few unrelated questions:

    1. In http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-3-of-n:

    Is it always better to use the erase/erase_ifs? Also when erasing everything? If so, how do you declare an overloaded erase function, that just takes the container and calls the erase_if helper with a predicate functor that always returns true (don't only use C++0x, so I can't use a lambda).

    Is something like this possible?

    namespace Functors {
    
    class TruePredicate {
        bool operator<T>()(T arg) {
            return true;
        }
    };
    
    } // Functors

    2. Is there a standard way of finding out if C++0x is enabled, so I could use this:

    #ifndef C++0x // or whatever way
      typedef NULL nullptr;
    #endif

    3. Is it possible, that VS11 can implement an option, e.g. Portability and Version?

    Reason for Portability: VS is unarguably my favorite dev IDE, but sometimes it gives messages like (not sure of the exact wording) "use fopen_s for safe version of fopen", which is only MS specific (I realized after porting my code). So I'd rather have a warning/error when using code that is MS/Win specific.

    Reason for Version: If the other machine dev env doesn't support C++0x, a warning/error would be good, not allowing those features (i.e. auto, lambdas etc.). I saw that some toolset version thing is available, but it says that VS2008 must be installed.

    Thanks for any info.

  • new2STLnew2STL

    @Deraynger: You can use the macro _CRT_SECURE_NO_WARNINGS for vc compiler stop suggest the secure versions of the C runtime, but they are only warnings.

  • new2STLnew2STL xkcd.com

    My apologize, it is a definition, not a macro. And there is also a _CRT_SECURE_NO_DEPRECATE.

    And for nullptr, you can infer the compiler version but you haven't a way to know if the compiler option -std=c++0x (in the case of gcc) is being used  Sad

  • @new2STL

    Thanks for the info, could be useful. But I also meant generally be able to throw a warning/error when using non-portable code. I thought, maybe STL would be in the position to see if something like that could be done. Also, MFC etc. should then throw an error, when it should be portable, and some other windows specific headers. That would make it very easy to port code.

    I'll see to use those definitions in my code. So is inferring the compiler version simple? If so, I could do a specific one for VS, since I only use XCode on the "other side", that totally lacks C++0x support (LLVM or old GCC 4.2). I guess that won't come too soon either Sad on the Mac side.

    Thanks again!

    @STL: Still wondering on my first question. myVector.clear(); as good as erase(myVector v) calling erase_if(v,MyTruePredicate);

    when erasing every element?

  • new2STLnew2STL xkcd.com

    @Deraynger: Some macro definitions for compilers here. For Visual Studio it is _MSC_VER and encodes the compiler version (1600 for VS10.0), for GNU have some problem, they have __GNUC__ separated for each major.minor.revision the suggestion is mix all in one __GNUC_VERSION__ (see the link).

    Clang (one of LLVM compilers) are beginning to support c++0x but in an early stage yet.

  • For future lectures I suggest:

    - More C0x new features as many will change the way one will/should program; Perhaps beginning with the FAQ items Stroustrup didn't have time to write yet in his 0x FAQ.

    - Maximizing portability. What is Microsoft doing to clearly delimitate C++ and C++/CLI in documentation, syntax, keywords etc? What is the best way to strictly limitate the use of code non-compliant with ISO C++?

     

  • C64C64

    Do you think that defining custom overloads for std::equal() (and similar for std::copy()) in release builds in a custom header (e.g. "OptimizedStdEqual.h") is possible with VS2008 and VS2010?

    #ifndef _DEBUG
    
    namespace std 
    {
    
    inline bool equal(const char * _First1, const char * _Last1, const char * _First2)
    {    // compare [_First1, _Last1) to [First2, ...)
        return (::memcmp(_First1, _First2, (_Last1 - _First1)*sizeof(char)) == 0);
    }
    
    inline bool equal(const short * _First1, const short * _Last1, const short * _First2)
    {    // compare [_First1, _Last1) to [First2, ...)
        return (::memcmp(_First1, _First2, (_Last1 - _First1)*sizeof(short)) == 0);
    }
    
    inline bool equal(const int * _First1, const int * _Last1, const int * _First2)
    {    // compare [_First1, _Last1) to [First2, ...)
        return (::memcmp(_First1, _First2, (_Last1 - _First1)*sizeof(int)) == 0);
    }
    
    inline bool equal(const long long * _First1, const long long * _Last1, const long long * _First2)
    {    // compare [_First1, _Last1) to [First2, ...)
        return (::memcmp(_First1, _First2, (_Last1 - _First1)*sizeof(long long)) == 0);
    }
    
    
    //
    // TODO: add signed/unsigned variations, too.
    //
    
    } // namespace std
    
    #endif // _DEBUG
    

    Or is this stomping on your STL code, causing subtle bugs or something?

    Thanks.

     

  • STLSTL

    Ben_Craig> Something I would like to see in future Advanced STL lectures would be a discussion of allocator trickiness, especially if you do any EBO (Empty Base Optimization) trickery.

    In fact, we've recently worked on this. I'll see what I can do.

    Ben_Craig> You may also want to discuss any special list::splice nastiness.

    Splicing between lists with different allocators hurts my head - fortunately, our code handles it. I think this is too specific to be the subject of a video, though.

    Ben_Craig> One other thing I am curious about... do the internal functions that take iterator tags get inlined to the point that no stack space is consumed by the tag instance?  Basically, is that function call completely free, or does it cost you 1 byte on the stack in various places?

    When inlined, this technique (tag structs for overload resolution) should be completely free, presenting absolutely no challenge whatsoever to the optimizer. When inlining doesn't occur, I believe that it has minor costs - but in that case the absence of inlining is a much bigger deal.

    Burkholder> Outstanding video!
    Deraynger> Awesome video, as usual!

    Thanks!

    Deraynger> Is it always better to use the erase/erase_ifs?

    Compared to what?

    Deraynger> Also when erasing everything?

    No. Use clear() - that tells a container to nuke itself from orbit as fast as possible.

    Deraynger> Is there a standard way of finding out if C++0x is enabled, so I could use this:

    That isn't the right question to ask, because C++0x consists of many features, compilers support different subsets, and those subsets are growing over time.

    In general, you'll need compiler version queries.

    Deraynger> So I'd rather have a warning/error when using code that is MS/Win specific.

    We have warnings for some of our non-Standard Core Language extensions, e.g. the Evil Extension allowing temporaries to bind to modifiable lvalue references. But not for others (e.g. C++98/03 didn't contain long long, but according to my knowledge we don't warn about that). And we typically don't have such warnings for our libraries.

    There's also the /Za switch, but please don't use that - it is buggy.

    Deraynger> Reason for Version: If the other machine dev env doesn't support C++0x, a warning/error would be good, not allowing those features (i.e. auto, lambdas etc.).

    You can submit suggestions to Connect.

    new2STL> And for nullptr, you can infer the compiler version but you haven't a way to know if the compiler option -std=c++0x (in the case of gcc) is being used

    Actually, GCC documents __GXX_EXPERIMENTAL_CXX0X__ for that purpose.

    CedricM> More C0x new features as many will change the way one will/should program; Perhaps beginning with the FAQ items Stroustrup didn't have time to write yet in his 0x FAQ.

    C++0x Core Language and especially Standard Library features are definitely potential topics.

    CedricM> Maximizing portability. What is Microsoft doing to clearly delimitate C++ and C++/CLI in documentation, syntax, keywords etc? What is the best way to strictly limitate the use of code non-compliant with ISO C++?

    Not really on topic for this series, sorry. As for native C++ versus C++/CLI, what you see on MSDN is what we've got. The best way to achieve portability is to be familiar with the Standard (so you don't accidentally write non-portable code), and then compile and test your code with multiple compilers.

    C64> Or is this stomping on your STL code, causing subtle bugs or something?

    Please DON'T do this. C++03 17.4.3.1 [lib.reserved.names]/1: "It is undefined for a C++ program to add declarations or definitions to namespace std or namespaces within namespace std unless otherwise specified. A program may add template specializations for any standard library template to namespace std. Such a specialization (complete or partial) of a standard library template results in undefined behavior unless the declaration depends on a user-defined name of external linkage and unless the specialization meets the standard library requirements for the original template."

    (Remember, there are no such things as partial specializations of function templates. Anything that looks like that is actually an overload, and adding overloads to namespace std is forbidden. As for explicit specializations of function templates and class templates, the "user-defined name" part is important - that prevents users from messing with machinery that's not their business.)

  • new2STL> Clang (one of LLVM compilers) are beginning to support c++0x but in an early stage yet.

    This is true, but I don't think Apple will use any newer version too soon, that makes it "useless". I do find it very unfortunate, since it would be really nice to use C++0x features, and I must say hats off to MS for implementing so much already, while most compilers are far behind. I mean just a nullptr on most compilers would be nice, and lambdas would be great, and unordered_map, and... oh wait, now I'm going too far Big Smile.

    @STL & @new2STL: Thanks for the answers, very appreciated!!!

    @STL: Is there any page where the VC11 features regarding C++0x are listed? Couldn't find anything by quickly searching googling for it.

  • STLSTL

    > Is there any page where the VC11 features regarding C++0x are listed?

     

    Not yet.


  • Of course, the one feature i ended up needing, vs2010 compiler didn't implement.

    "cannot convert parameter 2 from '`anonymous-namespace'::<lambda0>' to 'void (__cdecl *const &)(int)'"

    Yes, i'm talking about the new lambda revision that came after vs2010 was released.

    I know this is off topic but i'm hoping i will actually get an answer here.

    Would it be possible to get a beta version the the new vs11 compiler so i can get the new lambda support ?

    I'm currently using gcc (gooo open source! take that you closed src microsoft ;) )
    anyway gcc doesn't agree well with visual studio, not at all in fact since i'm forced to use make files.

    Reading black and white console output all day isn't fun.
    If you're a gcc user like me then you know what i'm talking about.

    Or is there a workaround i can use with vs2010 compiler to get around the issue temporarily until vs11 ?
  • STLSTL

    > Would it be possible to get a beta version the the new vs11 compiler so i can get the new lambda support ?

    Yes, when everyone else gets it.

    > Reading black and white console output all day isn't fun.

    The console is delicious.

    > Or is there a workaround i can use with vs2010 compiler to get around the issue temporarily until vs11 ?

    There isn't, unless you consider writing a local struct to be a workaround.

  • > Yes, when everyone else gets it.

    Would that change if i said "pretty please with a cherry on top" ?

    I use beta software all the time, i know the risks.
    ( Quite satisfying, when the software is released, i know it will work since i've reported and/or sent patches to the devs.
    From a dev to a dev communication, oh so nice, no bs/secrets/pr people, i wish official bug reports could be this efficient and time consuming/hassle free ) *cough* example: AMD 3d drivers w7 bug reports, going over 6 months and still not fixed. example 2: microsoft "by design"... *cough*

    > The console is delicious.

    Sure i can agree somewhat, if you exclude the excessive typing and lack of colors (colors improve readability)
    I wish gcc would add colors for warnings and errors. Perhaps i'm forced to write some kind of console wrapper to do the coloring

    > There isn't, unless you consider writing a local struct to be a workaround.

    I was thinking more of something i could add to my class so it accepts lambdas, like some template magic: if lambda use std::function...
    or similar...
  • STLSTL

    > Would that change if i said "pretty please with a cherry on top" ?

    No. What you're asking for is impossible.

    (However, I've set up a special scheme for Microsoft employees to try out my "nightly builds".)

    > I was thinking more of something i could add to my class so it accepts lambdas

    That's what std::function is for.

    (The lambdas v1.1 conversion to function pointer is useful when you're dealing with interfaces, like C-style APIs, that require function pointers.)

  • @Mr Crash:For an IDE that wraps gcc & g++, use the "Eclipse IDE for C/C++ Developers":
    http://www.eclipse.org/downloads

    I've used the Eclipse IDE for C/C++ Developers on Windows to wrap MinGW's version of gcc & g++ (i.e. gcc & g++ on Windows: http://sourceforge.net/projects/mingw/ ) ... and it works very well ... and is easy to understand ... and has lots of colors.  Wink  The default is not C++0x, so you'll need to add "-std=c++0x" by editing the properties of your C++ project in C/C++ Build / Settings / Tool Settings tab / GCC C++ Compiler / Miscellaneous / Other flags text field.  You'll need to add that to the Debug and Release configurations.  For the Release configuration, you also might want to add "-march=native" (or whatever architecture you're writing for) to the same text field; otherwise, the default instruction set that gets used is a little old.

    There is probably an easy way to make that "-std=c++0x" addition the default for all future projects, but I haven't had to worry about that yet.

    Hope This Helps,
    Joshua Burkholder

  • @Burkholder: Nice tip, it looked good but then i saw it needed java to run which is a big no no and also i don't like java since it doesn't integrate well with windows (according to the java devs it's due to microsoft not cooperating, (sarcasm) shocking, right Wink (/sarcasm) ) I use mingw and mingwx64 on my usb thumb drive so i can take it with me everywhere i go, the programs i use have to be portable. I would have liked to use vs2010 as IDE but as we all know it microsoft likes to make programs that integrate into the operating system *cough* internet explorer, office 2010, etc.. *cough* Sad But thanks for the suggestion and info i appreciate it Smiley
  • @Mr Crash:Unfortunately, the "Eclipse IDE for C/C++ Developers" does require the JRE 1.5 or higher to run.  There is a way to "install" the JRE without actually installing the JRE (i.e. no Windows registry and no admin rights) - place the bin folder of that unzipped JRE temporarily in the PATH and execute Eclipse with that temporarily revised path ... but that requires a little more leg work.  It's easier to just install Java. 

    I have never had a problem with Java on Windows.  The JRE and JDK on Windows have always played nicely for me ... and never interfered with anything.  I'm not a fan of Java ... I only develop using it when forced by requirements ... and I would always choose C# (on .NET/Mono) over Java (on JRE) for managed work, but Java has always worked for me ... so no M$ conspiracy theories here.  Wink

    If you really, really want to use Visual Studio, you could always extend Visual Studio by wrapping it around gcc/g++ yourself (like they did for IronPython Studio: http://ironpythonstudio.codeplex.com/ ).  Here's Microsoft's "Extending Visual Studio" page:
    http://msdn.microsoft.com/en-us/vstudio/ff718165.aspx

    Lastly, some of my friends like Bloodshed's Dev-C++ ... although I have never tried it myself.  It doesn't require Java.  Here's the site:
    http://www.bloodshed.net/devcpp.html

     Hope This Helps,
    Joshua Burkholder

  • new2STLnew2STL xkcd.com

    @Mr Crash: You can also use Code::Blocks, Its build over WxWidgets, so have ports to Linux, Windows, Mac etc And it is based on the L&F of VS6, its integrates with gcc, mingw, even with Windows SDK. (and are the spiritual successor of dev-c++).

    I have used Eclipse for a long time, and because my machine must have JRE instaled I have not problems in using the compressed version (no installs no hidden configs)

  • 2pRQb2pRQb

    The copy optimization code raised a question that why 'is_scalar' is used instead of 'has_trivial_assign' to determine the possibility to use memmove? Without knowing better, it seems weird that objects of type such as struct MyInt {int a;};now don't seem to get the memmove-optimization.

  • STLSTL

    2pRQb: As I mentioned, is_scalar is too conservative. I have a todo about extending this optimization - I've just added a note that we should use the trivial type traits. (This optimization is actually quite old, and predates <type_traits> - we've always been able to detect scalars through handwritten machinery.)

  • Am in withdrawal here Wink

  • Jia-Jium LeeJia-Jium Lee

    Thanks for the vedio.
    I would like to ask about a memory leak problem around std::ios_base when I use boost interprocess basic_vectorstream under VC++ (both 2008 and 2010). I don't know where is the proper place I should post it? Sorry for posting here!
    In boost\interprocess\streams\vectorstream.hpp there is a class base_vectorstream derived from std::basic_iostream
    code from vectorstream.hppbasic_vectorstream(std::ios_base::openmode mode                    = std::ios_base::in | std::ios_base::out)   :  basic_ios_t(), base_t(0), m_buf(mode){  basic_ios_t::init(&m_buf); }
    The constructor basic_vectorstream(std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) :it constructs the based std::basic_iostream with base_t(0)
    The based std::basic_iostream will constructs std::basic_istream by _Myis(_Strbuf, false) now _Strbuf == 0 as base_t(0)
    above std::basic_istream constructor basic_istream(_Strbuf, false) will call into _Myios::init(_Strbuf, _Isstd)
    _Myios (std::ios_base) calls into _Init() (std::ios_base)
    std::ios_base _Init() will new a locale by _Ploc = _NEW_CRT locale
    the "basic_ios_t::init(&m_buf);" called by basic_vectorstream constructor in vectorstream.hpp will new a locale again! It causes a memory leak problem.
    What is the suggestion to fix it? Change to below? Or it should be fixed in std::ios_base?
    basic_vectorstream(std::ios_base::openmode mode                    = std::ios_base::in | std::ios_base::out)   :  basic_ios_t(), base_t(&m_buf), m_buf(mode){}

  • Jia-Juim LeeJia-Juim Lee

    Repost for replacing above messy format.
    Thanks for the vedio.
     
    I would like to ask about a memory leak problem around std::ios_base when I use boost interprocess basic_vectorstream under VC++ (both 2008 and 2010). I don't know where is the proper place I should post it? Sorry for posting here!
     
    In boost\interprocess\streams\vectorstream.hpp there is a class base_vectorstream derived from std::basic_iostream
     
    code from vectorstream.hpp
    basic_vectorstream(std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
       :  basic_ios_t(), base_t(0), m_buf(mode)
    {  basic_ios_t::init(&m_buf); }
     
    The constructor basic_vectorstream(std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) :
    it constructs the based std::basic_iostream with base_t(0)
     
    The based std::basic_iostream will constructs std::basic_istream by _Myis(_Strbuf, false) now _Strbuf == 0 as base_t(0)
     
    above std::basic_istream constructor basic_istream(_Strbuf, false) will call into _Myios::init(_Strbuf, _Isstd)
     
    _Myios (std::ios_base) calls into _Init() (std::ios_base)
     
    std::ios_base _Init() will new a locale by _Ploc = _NEW_CRT locale
     
    the "basic_ios_t::init(&m_buf);" called by basic_vectorstream constructor in vectorstream.hpp will new a locale again! It causes a memory leak problem.
     
    What is the suggestion to fix it? Change to below? Or it should be fixed in std::ios_base?
     
    basic_vectorstream(std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
       :  basic_ios_t(), base_t(&m_buf), m_buf(mode)
    {}

  • SebastianSebastian

    >That isn't the right question to ask, because C++0x consists of many features, compilers support different subsets, and those subsets are growing over time.
    >In general, you'll need compiler version queries.
    It would be awesome if other compilers than just Clang implemented the feature check extension __has_feature:
    http://clang.llvm.org/docs/LanguageExtensions.html#feature_check
    Interestingly enough, browser script writers have long since learned that version queries (user-agent queries) are of the devil. But as C++ programmers, we're still stuck with essentially the same logic. "So _MSC_VER is defined. But does that mean it's VC++, or is it Intel pretending to be VC++? Let's check _ICL_VERSION - or what was it called? So, turns out I've got actual VC++, version 1400. Er, what real version does that correspond to? Does it have the feature I want?"
    It's pretty much black magic. This is so much prettier:
    #if __has_feature(cxx_variadic_templates)// variadic template implementation#else// emulation#endif

  • SebastianSebastian

    What's the point in having a WYSIWYG-style comment edit box when it doesn't actually IWYG?

  • STLSTL

    Deraynger: I filmed Part 3 today, about _ITERATOR_DEBUG_LEVEL, #pragma detect_mismatch, and /d1reportSingleClassLayout.

    Jia-Juim Lee> the "basic_ios_t::init(&m_buf);" called by basic_vectorstream constructor in vectorstream.hpp will new a locale again! It causes a memory leak problem.

    Surprisingly and obnoxiously, this is how the Standard works - init() is supposed to be called exactly once on an uninitialized object.

    It looks like this is already tracked by https://svn.boost.org/trac/boost/ticket/4031 which was filed a year ago, but still seems to be open.

  • SamSam

    @Charles: where's the new video, you said next week, it's now Saturday of that next week and it's nearly over, did something happen ?

  • @Charles: where's the new video, you said next week, it's now Saturday of that next week and it's nearly over, did something happen ?

    Wondering too, it's now after next week Wink

  • new2STLnew2STL

    The Visual C++ Weekly (26 Mar, 2011):  by Herb Sutter News flash: "This afternoon, the ISO C++ committee approved the final technical changes to the C++0x standard."!!!!!

  • STLSTL

    Part 3: http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Stephan-T-Lavavej-Advanced-STL-3-of-n

  • Michael KilburnMichael Kilburn

    Stephan, talking about getting rid of pointer arithmetic -- why compiler did not do it for you? Usually MSVC is pretty good -- what about asking someone from compiler development team?

    (Or maybe compiler decided that that extra multiplication overlaps with surrounding operations and causes no performance loss?)

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.