C++ Standard Library features in libhipcxx#

2026-10-02

5 min read time

Applies to Linux and Windows

If you are a C++ developer, then you know the C++ Standard Library (sometimes referred to as “The STL”) as what comes along with your compiler and provides things like std::string, std::vector, or std::atomic. It provides the fundamental abstractions that C++ developers need to build high quality applications and libraries.

By default, these abstractions aren’t available when writing HIP C++ device code because they don’t have the necessary __host__ / __device__ decorators, and their implementation may not be suitable for use in and across host and device code.

libhipcxx solves this problem by providing an opt-in, incremental, heterogeneous implementation of C++ Standard Library features:

  • Opt-in: It does not replace the Standard Library provided by your host compiler, meaning anything in std::.

  • Incremental: It does not provide a complete C++ Standard Library implementation.

  • Heterogeneous: It works in both host and device code, as well as passing between host and device code.

If you know how to use headers such as <atomic> or <type_traits> from the C++ Standard Library, then you know how to use libhipcxx. For code that must run in both host and device code, add cuda/std/ to the start of the include and cuda:: before the use of std::. Host-only code continues to use the plain <atomic> and std::atomic from your host compiler. The hip/std/ and hip::std:: spellings are equivalent and name the same types.

#include <cuda/std/atomic>

cuda::std::atomic<int> x;

Note

libhipcxx does not provide its own documentation for Standard Library features. Instead, libhipcxx documents which Standard Library headers are made available, and defers documentation of individual features within those headers to other sources, such as cppreference.

C++ standard version support#

libhipcxx is tested with C++17. C++20 is supported but not yet tested. Many features from newer standards are backported so they are available in earlier dialect modes. For example, several C++20 chrono calendar types are available in C++14 mode, and many concepts are usable as type traits from C++17.

Some headers require a minimum dialect:

Minimum dialect

Headers

C++20

<bit>, <concepts>, <span>, <source_location>

C++23

<expected>, <mdspan>

C++26

<inplace_vector>, <linalg>

For the complete per-header dialect requirements, see the Standard API feature table.

Available headers#

libhipcxx provides conforming, host-and-device implementations of a subset of the C++ Standard Library. The Standard API reference lists every supported header together with its cuda/std/ include path and minimum C++ dialect.

Headers span the following groups:

Group

Headers

Notes

Synchronization

  • <atomic>

Containers

  • <array>

  • <span>

  • <mdspan>

  • <inplace_vector>

Numerics

  • <ratio>

  • <bit>

  • <complex>

  • <linalg>

  • <numbers>

  • <numeric>

Ranges

  • <iterator>

  • <ranges>

Concepts and subrange only. Range algorithms and views are not implemented.

Time

  • <chrono>

Timezone support and steady_clock are not available. The host and device clocks are not synchronized.

Concepts

  • <concepts>

Utilities

  • <type_traits>

  • <utility>

  • <tuple>

  • <optional>

  • <expected>

  • <variant>

  • <functional>

  • <bitset>

  • <memory>

  • <initializer_list>

  • <source_location>

  • <version>

Type support

  • <limits>

  • <climits>

C library compatibility

  • <cassert>

  • <cfloat>

  • <climits>

  • <cmath>

  • <cstddef>

  • <cstdint>

  • <cstdlib>

  • <cstring>

  • <ctime>

GPU-specific extensions#

Beyond the conforming Standard Library subset, libhipcxx provides GPU-specific extensions under the cuda:: (or hip:: — both are equivalent) namespace. These cover areas such as thread-scope atomics, warp intrinsics, async memory operations, and GPU math utilities that have no equivalent in host-only C++.

See C++ Standard Library extensions in libhipcxx for the full list, and HIP-specific abstractions and namespaces for an explanation of the namespace hierarchy.

Unsupported features#

Several APIs from the upstream libcudacxx project are not supported in libhipcxx because they depend on NVIDIA hardware or NVIDIA PTX instructions. These include the synchronization primitives <cuda/std/latch>, <cuda/std/barrier>, <cuda/std/semaphore>, their scoped cuda:: equivalents, <cuda/pipeline>, <cuda/annotated_ptr>, and the PTX instruction wrappers in <cuda/ptx>.

For the complete list, see Limitations and unsupported APIs.