Favicon of Abseil

Abseil

Abseil is Google's open-source C++17 library collection with Swiss table containers, string utilities, status handling, and more.

Abseil website screenshot
Abseil GitHub repository preview

Abseil is a collection of C++ library code maintained by Google, built to augment (not replace) the C++ standard library. It's pulled directly from Google's internal codebase, so the code has been tested at scale and is used in production across many Google projects. It targets C++ developers who want battle-tested utilities for things the standard library handles poorly or not at all: hash tables, string formatting, time handling, error propagation, and concurrency primitives.

The library fills gaps left by the standard library and, in some cases, offers alternatives the Abseil team found better suited to large-scale production use. Each component is documented as either filling a missing piece or providing a deliberate alternative to std equivalents.

Key features

  • Swiss table containers: high-performance unordered containers (absl::flat_hash_map, absl::flat_hash_set, etc.) in the container library.
  • absl::Status and StatusOr: structured error handling without exceptions, in the status library.
  • absl::Mutex: a synchronization primitive offered as an alternative to std::mutex, part of the synchronization library.
  • Hashing framework: default hash functors and a consistent hashing framework in hash.
  • String utilities: formatting, parsing, and manipulation helpers in strings.
  • Time and timezone handling: abstractions for absolute time points, durations, and timezone-aware formatting in time.
  • 128-bit integers and bit math: numeric types and C++20-style bitwise functions in numeric.
  • Command-line flags: a flags library for defining and parsing binary/library flags.
  • Logging macros: LOG and CHECK macros with pluggable output destinations in log.
  • absl::Cleanup: a scope-exit callback type in the cleanup library.
  • CRC checks: cyclic redundancy check computation in crc.
  • Debugging helpers: leak checking, stack traces, and symbolization in debugging.

Ideal use cases

Abseil fits C++17 (or later) projects that want standard-library-adjacent utilities without writing them from scratch or pulling in heavier frameworks. It's a good match for performance-sensitive codebases (hash tables, string handling) and for teams that already use Bazel or CMake, since those are the officially supported build systems.

It works well if a project wants absl::Status-style error handling instead of exceptions, or needs reliable timezone-aware time handling. It also suits teams willing to track the "live-at-head" model, since Abseil recommends updating to the latest master commit regularly, though Long Term Support releases exist for projects that can't do that.

It's not a good fit for projects locked into pre-C++17 compilers, since Abseil requires C++17 compliance. It's also not ideal for small, dependency-averse projects where pulling in a large library collection outweighs the benefit of a few utility functions. Projects using build systems other than Bazel or CMake will need to do extra integration work since those two are the only officially supported options.

Installation

Abseil doesn't ship as a typical package; it's a source library built alongside your project using Bazel or CMake.

Follow the official Quickstart for environment setup, downloading the code, and running tests:

https://abseil.io/docs/cpp/quickstart

For Bazel-based projects, add Abseil as a dependency per the Bazel quickstart linked above.

For CMake-based projects, check the CMake-specific instructions:

CMake/README.md

and the CMake Quickstart:

https://abseil.io/docs/cpp/quickstart-cmake

Once integrated, include the relevant Abseil headers in your code, for example:

#include "absl/strings/str_cat.h"
#include "absl/container/flat_hash_map.h"

int main() {
  absl::flat_hash_map<std::string, int> counts;
  std::string message = absl::StrCat("hello", " ", "world");
}

Check the supported compiler, platform, and build tool versions against Google's Foundational C++ Support Policy table before integrating, since Abseil tracks a specific support matrix rather than supporting every toolchain indefinitely.

Categories:

Frequently asked questions

Share:

Stars
18.2K
Forks
3.2K
Last commit
10 hours ago
Repository age
9 years
License
Apache-2.0
Self-hosted
No
Activity score
82/100
View Repository
Built with:
Ad
Favicon

 

  
 

Similar to Abseil

Favicon

 

  
 
Favicon

 

  
 
Favicon