Technology

CppCon 2019: The C++20 Standard Library – Beyond Ranges

Jeff Garland

jeffgarland

Intro

Not about ranges

  • Up to date with respect to Cologne
  • Summary
  • boost datetime

Goals

  • io – formatted output (15min)
  • container and algorith updates (12min)
  • chrono (8min)
  • concurrency (10min)
  • misc(5min)
  • bit manip (5min)

Not goals

  • ranges
  • concept
  • spaceship
  • concurrency other topics
  • char8_t, u8string_view, etc
  • constexpr, …

environment

std::format

  • python style formatting
  • faster and less overhead
  • string s = fmt::format(“{} there {}\n”, “hello”, “world”);
  • floating point
  • rich languate for fill, alignment
  • custom types
    • template specialization
  • fmt diagnostics/saefty
  • runtime diagnostic (std::exception)
  • wg21.link/p0645
  • https://github.com/fmtlib/fmt

syncbuf and osyncstream

stringstream and basic_stringbuf

  • control of buffer allocator
  • stringstream.view() so no need to copy string
  • p0408

container and algorithm

  • span view over contiguous seqnce
  • cheap to copy
  • constant time complexity
  • mutable
  • P0122
  • github.com/tcbrindle/span
  • contains()

    for associative containers

  • p0458
  • uniform container erasure
  • library fundamentals v2

chrono

  • structure/field types like year_month_day
  • calculation types ike sys_days, time_point, seconds
  • field types sed for i/o and conversions
  • no exceptions
  • fmt i/o
  • https:://github.com/HowardHinnand/date
  • p0355

Concurrency

  • jthread and stop_token
  • atomic<shared_ptr> and weak_ptr<>
    • p0718
  • jthread automatically joins in destructor
  • stop_token provides cooperator shutdown
  • p0660 (wording) p0660r0 (motivation)
  • github.com/josuttis/jthread
  • atomic_ref

misc

  • string_view starts_with() and ends_with()
  • source_location
    • modern replace for FILE and LINE
    • static consteval source_location current() noexcpt;
    • p1208
  • math constants
    • <math>
    • p0631
    • 1midpoint()` difficult
  • bit manipulation
    • <bit>
    • p0553
  • bit_cast
    • p0476
  • endian
    • p0463
Technology

CppCon 2019: C++-20 at 40

Bjarne Stroustrup

  • Introduced b a high school student

  • Stability and evolution
  • “A tour of C++”, 2nd edition
  • Distinguish betwee what’s lega and what’s effective
    • Better tool support, eg C_+ core Guidlines
  • C++: principled and eclectic
  • C++ a general purose programming language for the defn, impl and use of lightweight abstractions
  • “We don’t really like C++ but is it the only thing that works”
  • C++ high level aims
    • Evolutionary (stable, gradual adoption)
    • Make simple things simple
    • Zero-overhead principle
    • Aim high: change the way we design and implement software and we think
  • Key C++ “Rules of thumb”
    • Static type sisteym build-in and user-defined
    • Value and referenc semantics
    • Direct use of machine and operating system resources
      • Layers of abstraction
        • The Onion principle:The more layers you peel off, the more you cry
    • Systematic and generl resource management (RAII)
      • Construct/destructor paris
      • Every resource must have an owner; don’t use built-in pointers (T*) to manage
    • Support composition of software from separatelhy developed parts
      • Modules
    • Support for generic programming
      • write code that works for types tat meet abstract requirements
      • requiremensts are defined as concepts
    • Support fo compile-time programming
      • const_expr
      • Move computaton from run-time to compile-time
    • Support for object-oriented programming
      • Still useful and popular
      • Need reference semantics
      • Don’t need run-time; use static resolution (variant)
      • See
        overloaded

        which do not ake it into c++20

    • Concurrency through libraries supported by intrinsics
      • mutex, RAII
      • atomics
    • C++ is tunable and evolves
      • Always measure
    • Things work in combination
    • Library design is language desing; language design is library design
    • cppreference.com/w/cpp/libs
    • Chrono
    • You have to raise the level abstraction for tools to enforce type and resource-safe C++
    • These rules are about 40 years old
    • C++2o the best approximation of C++’s ideals (so far)
  • The future
    • C++23:
      • Completes C++20
      • Plus: standard modules, library support for coroutines, executors and netowrking
      • Maybe: static reflection, pattern match
  • Questions
    • Something about co_await and threads
    • How to deal with legacy code
      • In new code use modern features
      • Either try and encapsulate
      • Need more tooling
    • What feature most affected c++11:
      • const_expr
      • basic support for concurrent programming
    • What feature most affected c++20:
      • concepts will make generic much simpler, elegant, adn useful
      • modules should improve our compile speeds (5-10 times?). Major advantage is from cleaning up your code.
    • Not pay for things you use. However someone has to pay $ for implementing these features
      • It’s better to put the burden on implementers then users. 50,000 users for 5-10 implementors
    • Are there plans to add features to enforce ownership checks at compile time?
      • Use static enforced coding guideless to enforce “good” coding standards instead of “legal” codes.
    • Cyril from Bloomberg. Would you discourage use of runtime polymorphism?
      • Does someting really need hierarchis and runtime/dynamic types
Technology

How Journalists Covered the Rise of Mussolini and Hitler

Bundesarchiv bild 146 1969 065 24 munchener abkommen ankunft mussolini wr jpg 800x600 q85 crop

When Hitler’s party won influence in Parliament, and even after he was made chancellor of Germany in 1933 – about a year and a half before seizing dictatorial power – many American press outlets judged that he would either be outplayed by more traditional politicians or that he would have to become more moderate. Sure, he had a following, but his followers were “impressionable voters” duped by “radical doctrines and quack remedies,” claimed The Washington Post. Now that Hitler actually had to operate within a government the “sober” politicians would “submerge” this movement, according to The New York Times and Christian Science Monitor. A “keen sense of dramatic instinct” was not enough. When it came to time to govern, his lack of “gravity” and “profundity of thought” would be exposed.

Source: How Journalists Covered the Rise of Mussolini and Hitler