Making Iterators, Views and Containers Easier to Write with Boost.STLInterfaces - Zach Laine CppCon

Sdílet
Vložit
  • čas přidán 4. 06. 2024
  • cppcon.org/
    github.com/CppCon/CppCon2020/...
    ---
    Writing standard-compliant iterators is surprisingly easy to get wrong. Standard containers are tedious to write, because they have such large interfaces, involving lots of similar operations. For many years, Boost.Iterator's iterator_facade and iterator_adaptor were the state of the art for automating the creation of iterators with minimal effort. However, that library has not kept up with the evolution of C++, particularly with regard to constexpr and noexcept.
    Boost.STLInterfaces is a newly-accepted Boost library that solves these problems for authors of iterators and sequence containers. It does this using the same approach as C++20's std::ranges::view_interface. The view_interface template is a CRTP base that implements all the possible view member functions when inherited by a derived type containing just begin() and end(). This pattern allows the user to use Boost.STLInterfaces to write correct iterators, views, and/or sequence containers, requiring surprisingly little code.
    ---
    Zach Laine
    Sr. Principal Software Engineer, Cadence Design Systems
    Zach Laine has been using C++ in industry for 15 years, focusing on data visualization, numeric computing, games, generic programming, and good library design. He finds the process of writing bio blurbs to be a little uncomfortable.
    ---
    Streamed & Edited by Digital Medium Ltd - events.digital-medium.co.uk
    events@digital-medium.co.uk
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*
  • Věda a technologie

Komentáře • 2

  • @keris3920
    @keris3920 Před 3 lety +1

    Brilliant. Interface/contract-based programming makes implementation much easier on on newcomers, which is something I think the could improve on. Consider me an adopter.

  • @peepzorz
    @peepzorz Před 3 lety

    @7:40 For your comparison operators = , is there a good reason to also call operator== ? I would think its more efficient to just logical negate the "opposite" operation, so only operator< is required for those. Like this (hopefully youtube comment doesn't mangle code paste here):
    operator() { return rhs < lhs; }
    operator rhs); }
    operator>=() { return !(lhs < rhs); }