SimplifyC++ Article
LLVM 22.1.8 and C++26: the important distinction
LLVM 22.1.8 and C++26: the important distinction
LLVM 22.1.8 itself does not introduce a separate batch of C++26 features. It is a patch-level release published on June 16, 2026, mainly consolidating fixes on the LLVM 22 branch. The C++ feature set was introduced with Clang/libc++ 22.1.0 and carried into 22.1.8.
C++26 support comes from two components:
Clang 22: C++ language syntax and semantics.
libc++ 22: C++ Standard Library facilities.
New Clang 22 language support
The principal new C++26 language feature in Clang 22 is the beginning of support for P2686R5: constexpr structured bindings.
struct Point { int x; int y;};
constexpr auto sum(){ constexpr auto [x, y] = Point{10, 20}; return x + y;}
static_assert(sum() == 30);However, the implementation is explicitly partial:
Arrays and aggregate classes are supported.
References in
constexprstructured bindings are not fully supported.Tuple-like decomposition, such as
std::tupleandstd::array, is not fully supported.
Therefore this may work:
constexpr auto [x, y] = Point{1, 2};while more sophisticated tuple-like cases may still fail.
Clang 22 also adds internal comparison builtins named:
__builtin_lt_synthesizes_from_spaceship__builtin_gt_synthesizes_from_spaceship__builtin_le_synthesizes_from_spaceship__builtin_ge_synthesizes_from_spaceshipThese allow library implementers to determine whether relational operators were synthesized from operator<=>, potentially avoiding redundant comparisons. They are compiler facilities rather than ordinary portable C++26 APIs.
The larger improvements are in libc++ 22
libc++ 22 contains considerably more C++26 progress than the Clang frontend.
std::optional<T&>
Reference specializations of std::optional are now implemented:
int main(){ int value = 42;
std::optional<int&> ref = value; *ref = 100;
// value is now 100}The follow-up requirement making optional<T&> trivially copyable is also included.
std::views::indices
P3060R3 introduces a convenient counting view:
for (auto index : std::views::indices(10)) { // index is 0 through 9}This is more expressive than manually constructing an iota_view starting at zero.
std::optional becomes a range
An engaged optional can behave as a single-element range, while an empty one behaves as an empty range:
std::optional<int> result = 42;
for (int value : result) { // Executes once}In libc++ 22, this feature is still guarded by:
-fexperimental-library
Therefore it should not yet be treated as an unrestricted production facility in this release.
std::is_within_lifetime
P2641R4 adds a facility for checking whether a union member is currently within its lifetime, particularly useful in constant evaluation and low-level implementations.
Better move-only comparison concepts
The concepts:
std::equality_comparable_withstd::totally_ordered_withstd::three_way_comparable_withwere updated to work correctly with move-only types rather than unnecessarily depending on copyability.
Additional C++26 library work
libc++ 22 also implements:
| Proposal | Facility |
|---|---|
| P2592R3 | Hashing for std::chrono value types |
| P3044R2 | Constructing a sub-string_view directly from a std::string |
| P3223R2 | Less surprising behavior for std::istream::ignore |
| P2835R7 | Access to the object address represented by std::atomic_ref |
| P2944R3 | Improved comparisons for std::reference_wrapper |
| P3567R2 | Corrections to the C++23/26 flat associative containers |
| P1789R3 | Library support for expansion statements |
libc++ 22 additionally completes zip-family range work from P2321R2, although that proposal belongs primarily to C++23 rather than C++26.
What is still missing
LLVM 22 is not a complete C++26 implementation. Major areas still unavailable or incomplete include:
Static reflection
Contracts
Throwing exceptions during constant evaluation
Trivial unions
Static storage for braced initializers
Full
constexprstructured bindingsFull expansion-statement language support
The official Clang status page describes C++26 support as partial and uses the working-draft mode name c++2c.
How to enable it
For Clang language support:
clang++ -std=c++2c source.cppFor LLVM’s libc++ implementation:
clang++ -std=c++2c -stdlib=libc++ source.cppFor experimental library features such as optional range support:
clang++ -std=c++2c -stdlib=libc++ -fexperimental-library source.cppClang can use either libc++ or another platform library. Consequently, using Clang 22 with GCC’s libstdc++ or Microsoft’s STL gives you Clang’s C++26 language support, but not necessarily the new libc++ 22 library facilities.
Overall: LLVM 22.1.8 is a useful C++26 experimental toolchain, especially with libc++ 22, but the core-language advance over Clang 21 is relatively modest. The strongest additions are optional<T&>, views::indices, optional range support, lifetime inspection, and several comparison, ranges, atomic, string-view, and chrono improvements.