C++Now 2018: Alan Talbot “Moving Faster: Everyday Efficiency in Modern C++”

Поделиться
HTML-код
  • Опубликовано: 26 дек 2024

Комментарии • 20

  • @courier7049
    @courier7049 6 лет назад +32

    Set speed to 1.25 for best experience.

  • @NITHISHCHAUHAN829
    @NITHISHCHAUHAN829 6 лет назад +2

    Very well said Sir. Very thoughtful talk.Excellent examples in the slides.

  • @akarshy
    @akarshy 5 лет назад

    would 43:04 actually be optimal? i wonder if we might get a strlen call due to the indirection

  • @nicolasbertrand3932
    @nicolasbertrand3932 6 лет назад

    That was quite interesting, for good usage of parameters and return values for instance

  • @troylowry4239
    @troylowry4239 6 лет назад

    Good presentation.
    Alan looks like a hybrid between Bryan Cranston and Kiefer Sutherland

  • @jonesconrad1
    @jonesconrad1 6 лет назад

    was short string optimization not prohibited by the latest standard ?

    • @SebastianHasler
      @SebastianHasler 6 лет назад

      No. Copy-on-write was prohibited from C++11 on.

    • @jonesconrad1
      @jonesconrad1 5 лет назад

      @@SebastianHasler thanks I couldn't remember

  • @davidporterrealestate
    @davidporterrealestate 6 лет назад

    Interesting intro

  • @-abigail
    @-abigail 6 лет назад

    "Geometric growth behavior makes large vectors impossible unless the maximum size is known ahead of time" - as far as I can tell, this is false. Appending n items to an empty vector would perform O(log n) allocations, and O(n) move constructions and destructions, so overall there's only a linear amortized overhead, same as a deque.

    • @EricNorige
      @EricNorige 6 лет назад

      The example from the video was if you have 4GB ram and 2GB vector that you need to add one more element to, the doubling of reserved size will take up all memory. For this kind of "large", there is a real problem (maybe modulo overcommit capability of OS).

    • @alantalbot7110
      @alantalbot7110 6 лет назад

      Exactly. But it's actually worse than that, because you can't (typically) grow memory in place, so if your growth factor is 2, you need space for a new vector of twice the size, so temporarily you need three times the memory used by the current vector.

    • @alantalbot7110
      @alantalbot7110 6 лет назад +1

      See my answer to Eric Norige below about the growth issue. As for the number of moves, it is O(n), but for typical implementations it will be between 2 and 3 times n, which might matter, especially if your elements do not benefit from move semantics. So pre-reserving is always desirable if you know the final size (or know a reasonable upper bound).

    • @ALivingDinosaur
      @ALivingDinosaur 6 лет назад

      > you can't (typically) grow memory in place
      Even if the low-level allocator/memory manager supports in-place reallocations, std::vector wouldn't be able to use this feature simply because std::allocator's interface doesn't provide any equivalent to realloc() from the C standard library.

  • @davidporterrealestate
    @davidporterrealestate 6 лет назад +2

    Get a glass