Abseil Blog

    B-tree Ordered Containers

    12 Aug 2019

    By Evan Brown, Engineer

    The Abseil container library now includes B-tree containers that generally conform to the STL sorted container APIs:

    • absl::btree_set (meant to replace usage of std::set)
    • absl::btree_map (meant to replace usage of std::map)
    • absl::btree_multiset (meant to replace usage of std::multiset)
    • absl::btree_multimap (meant to replace usage of std::multimap)

    You use a B-tree container just as you would an STL ordered container:

    #include "absl/container/btree_map.h"
    absl::btree_map<int, std::string> ducks =
        {{2, "dewey"}, {1, "huey"}, {3, "louie"},};
    // Prints "huey, dewey, louie "
    for (const auto& n : ducks) {
        std::cout << n.second << ", ";

    B-trees have a different implementation from STL std::map containers, which require binary trees commonly implemented as red-black trees. While a red-black tree is limited to single-element nodes, with precisely two children, a B-tree may contain multiple values per node (M), with each node having (M+1) children. Having more values and children per node is more cache friendly because nodes are generally allocated separately so accessing additional nodes often results in cache misses.

    Read more

    Abseil Flags

    09 May 2019

    By Gennadiy Rozental, Abseil Engineer

    Abseil is very happy to announce the release of the Abseil Flags library. Abseil’s flags library provides a standard, readable way to pass command-line values to a program.

    #include <iostream>
    #include <string>
    #include "absl/flags/flag.h"
    #include "absl/flags/parse.h"
    ABSL_FLAG(std::string, name, "you", "Name of the person to greet");
    int main(int argc, char** argv) {
      absl::ParseCommandLine(argc, argv);
      std::cout << "Hello " << absl::GetFlag(FLAGS_name) << "!" << std::endl;
      return 0;
    $ greet
    Hello you!
    $ greet --name=Alice
    Hello Alice!

    Read more

    Abseil Support for CMake

    02 Apr 2019

    By Jon Cohen, Abseil Engineer

    CMake is a popular tool used to build multi-platform C++ projects. Abseil has had unofficial CMake support for some time, but support has never been as robust as that for Bazel. We are happy to announce that Abseil now fully supports the CMake build system.

    Read more

    Automated Upgrade Tooling for Abseil

    20 Dec 2018

    By Alex Strelnikov, Abseil Engineer

    As we promised when we released our Compatibility Guidelines, we have developed a process for announcing and handling any API-breaking changes we may need to make within the Abseil code base. Our C++ Automated Upgrade guide outlines this process, which consists of clang-tidy tooling and associated communication regarding the change. A list of all such tools will be listed on our Upgrade Tools page.

    At this time, we are also releasing our first such tool: a clang-tidy check for removing bug-prone implicit conversions in calls to several absl::Duration functions.

    Read more

    CppCon 2018: Modern C++ Design

    29 Nov 2018

    Titus Winters and Modern C++

    By Tom Manshreck, Abseil Tech Writer

    CppCon 2018 was held in Bellevue, WA at the end of September.

    C++ has changed a lot since the transformative introduction of C++11. It is now all too apparent that C++ API Design itself also needs to change as the lessons learned about, for example, type design become more understood.

    Titus Winters reflects on the changes to C++ and how the introduction of new principles such as move-only types have affected API design in this two-part talk.

    In the first part, Titus focuses on parameter passing and an API’s overload set in providing a powerful conceptual framework for API design. In the second part, we focus on the properties of well-designed types, and how to think about things like Regularity. We discuss how Regularity affects the design of non-owning reference types like string_view or span.

    If you haven’t already, check out Titus’ original blog post on “Revisiting Regular Types” for more background information.

    Read more

Subscribe to the Abseil Blog