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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.