# C++ Standards Supported by Abseil C++: Requirements and Compatibility

> Discover Abseil C++ supported C++ standards. Abseil requires C++17 and supports C++20 and C++23 features for enhanced development.

- Repository: [Abseil/abseil-cpp](https://github.com/abseil/abseil-cpp)
- Tags: deep-dive
- Published: 2026-07-19

---

**Abseil C++ requires C++17 as its minimum supported language standard and optionally enables C++20 and C++23 features when available.**

The Abseil C++ library (`abseil/abseil-cpp`) is a collection of C++ library code designed to augment the C++ standard library. Understanding which **C++ standards supported by Abseil** are required helps developers configure their build systems correctly and take advantage of modern language features.

## Minimum C++ Standard Requirement

Abseil C++ strictly requires **C++17** as the baseline language version. The project no longer supports C++14 or earlier standards.

According to the repository's [`README.md`](https://github.com/abseil/abseil-cpp/blob/main/README.md) (lines 4-5), the code is explicitly declared as "compliant to C++17". This requirement is reinforced throughout the codebase via implementation comments. For example, [`absl/types/variant.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/variant.h) contains the comment "Now that C++17 is required" at line 20, indicating the library has transitioned from polyfill implementations to standard library facilities. Similar comments appear in [`absl/types/optional.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/optional.h) (line 20) and [`absl/strings/string_view.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/strings/string_view.h) (lines 20-21), confirming that fundamental types like `absl::optional` and `absl::string_view` now rely on C++17's `std::optional` and `std::string_view`.

### Evidence from Source Documentation

The C++17 requirement is documented in several key header files:

- [`absl/types/variant.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/variant.h) (line 20): Contains implementation notes stating C++17 is now required
- [`absl/strings/string_view.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/strings/string_view.h) (lines 20-21): Documents the transition to standard `std::string_view`
- [`absl/types/optional.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/optional.h) (line 20): References the C++17 requirement for optional types

These comments reflect the library's architectural decision to depend on C++17's guaranteed language features and standard library components.

## Optional Support for C++20 and C++23

While C++17 is mandatory, Abseil C++ uses conditional compilation to leverage **C++20** and **C++23** features when the compiler supports them. The library uses preprocessor checks like `__cplusplus >= 202002L` to detect standard versions and enable enhanced functionality.

### C++20 Feature Detection

In [`absl/types/span.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/span.h) (lines 33-34), the codebase uses preprocessor guards to handle constexpr `std::span` features available in C++20:

```cpp
#if __cplusplus >= 202002L
  // C++20 specific constexpr handling
#endif

```

Abseil also detects C++20's three-way comparison operator (`<=>`) and enhanced constexpr capabilities, enabling more compile-time evaluations when building with `-std=c++20` or higher.

### C++23 Considerations

When compiled with C++23, Abseil can utilize newer standard library features such as `std::ranges`. However, these are strictly optional optimizations—the library maintains full functionality under pure C++17 compilation.

## Build System Configuration

Both CMake and Bazel build configurations enforce the C++17 minimum requirement.

The top-level [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt) sets `CMAKE_CXX_STANDARD` to 17 or higher, ensuring the compiler flag `-std=c++17` is applied. Similarly, the Bazel build rules in `BUILD.bazel` configure `copts` to specify C++17 as the compilation standard. Attempting to build with an older standard results in compilation errors due to missing language features.

## Code Examples

The following example compiles under the required C++17 standard:

```cpp
#include "absl/strings/string_view.h"
#include "absl/status/status.h"

absl::Status DoWork(absl::string_view input) {
  if (input.empty()) return absl::InvalidArgumentError("empty");
  return absl::OkStatus();
}

```

This code uses `absl::string_view`, which since the C++17 requirement has become an alias for `std::string_view`.

For projects using C++20, Abseil enables additional features:

```cpp
#if __cplusplus >= 202002L
#include <compare>
#include "absl/types/optional.h"

absl::optional<int> CompareValues(int a, int b) {
  if (auto cmp = (a <=> b); cmp == std::strong_ordering::less) {
    return a;
  }
  return b;
}
#endif

```

The second snippet activates only when the compiler reports C++20 support, demonstrating Abseil's forward compatibility strategy.

## Summary

- **C++17 is required**: Abseil C++ requires C++17 as the minimum language standard, as documented in [`README.md`](https://github.com/abseil/abseil-cpp/blob/main/README.md) and implementation headers like [`absl/types/variant.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/variant.h).
- **C++20 is optional**: The library detects C++20 via `__cplusplus >= 202002L` and enables additional constexpr and comparison features.
- **C++23 support**: Newer standards are supported opportunistically but not required.
- **Build enforcement**: Both CMake (`CMAKE_CXX_STANDARD`) and Bazel configurations enforce the C++17 minimum.

## Frequently Asked Questions

### Does Abseil support C++14 or earlier standards?

No. Abseil C++ explicitly requires C++17 as the minimum version. Header files such as [`absl/types/optional.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/optional.h) and [`absl/types/variant.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/variant.h) contain comments indicating that C++17 is now required, and the library relies on standard library features like `std::string_view` and `std::optional` that were introduced in C++17.

### Can I use Abseil with C++20 or C++23?

Yes. Abseil C++ is compatible with C++20 and C++23. When you compile with these newer standards, Abseil detects them using preprocessor checks like `__cplusplus >= 202002L` and enables enhanced features such as three-way comparison operators and extended constexpr support. However, C++17 remains the baseline requirement.

### How does Abseil detect which C++ standard is being used?

Abseil uses the predefined preprocessor macro `__cplusplus` to detect the C++ standard version. For example, in [`absl/types/span.h`](https://github.com/abseil/abseil-cpp/blob/main/absl/types/span.h) (lines 33-34), the code checks `#if __cplusplus >= 202002L` to conditionally enable C++20-specific features. This allows the library to maintain backward compatibility while taking advantage of newer language features when available.

### What build configuration is needed to compile Abseil?

You must configure your build system to use at least C++17. In CMake, this means setting `CMAKE_CXX_STANDARD` to 17 or higher in your [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt). For Bazel builds, ensure your toolchain specifies `-std=c++17` or newer. The Abseil repository's own [`CMakeLists.txt`](https://github.com/abseil/abseil-cpp/blob/main/CMakeLists.txt) enforces this minimum requirement automatically.