C++ language support

Apple supports C++ with the Apple Clang compiler (included in Xcode) and the libc++ C++ standard library runtime (included in SDKs and operating systems). The compiler and runtime are regularly updated to offer new functionality, including many leading-edge features specified by the ISO C++ standard.

    Supported features

    The following tables list support for ISO C++ standard features available on Apple platforms and in the Apple Clang compiler, as well as links to related documentation. While most features are supported by all Apple operating systems, some features depend on specific OS capabilities or require support in the libc++.dylib shared library provided with the OS. Code that uses those features should be guarded by the minimal deployment target check as noted.

    C++23

    Feature Paper Notes
    De-deprecating volatile compound operations. P2327R1 Requires Xcode 15
    Support for #warning P2437R1 Requires Xcode 15
    Remove non-encodable wide character literals and multicharacter wide character literals P2362R3 Requires Xcode 15
    Delimited escape sequences P2290R3 Requires Xcode 15
    Named universal character escapes P2071R2 Requires Xcode 15
    Support for UTF-8 as a portable source file encoding P2295R6 Requires Xcode 15
    Relax requirements on wchar_t to match existing practices P2460R2 Requires Xcode 15
    Multidimensional subscript operator P2128R6 Requires Xcode 14.3 or later
    Non-literal variables (and labels and gotos) in constexpr functions P2242R3 Requires Xcode 14.3 or later
    auto(x): decay-copy in the language P0849R8 Requires Xcode 14.3 or later
    Literal suffix uz, z for size_t, ssize_t P0330R8
    Make () in lambdas optional in all cases P1102R2
    if consteval P1938R3
    Allow duplicate attributes P2156R1
    Narrowing contextual conversions to bool P1401R5
    Trimming whitespaces before line splicing P2223R2
    C++ identifier syntax using unicode standard annex 31 P1949R7
    Mixed string literal concatenation P2201R1
    Character sets and encodings P2314R4
    Consistent character literal encoding P2316R2
    Preprocessing directives elifdef and elifndef P2334R1
    Extend init-statement to allow alias-declaration P2360R0
    Attributes on lambda expressions P2173R1
    Make declaration order layout mandated P1847R4
    Features implemented in the libc++ library
    Formatting ranges P2286R8 Available in Xcode 15.3
    ranges::to : A function to convert any range to a container P1206R7 Available in Xcode 15.3
    move_iterator<T*> should be a random access iterator P2520R0 Available in Xcode 15.3
    constexpr type_info::operator==() P1328R1 Available in Xcode 15.3
    Formatting thread::id P2693R1 Available in Xcode 15.3
    Monadic operations for std::expected P2505R5 Available in Xcode 15.3
    Making multi-param constructors of views explicit P2711R1 Available in Xcode 15.3
    std::invoke_r P2136R3 Available in Xcode 15.3
    Relaxing range adaptors to allow for move only types P2494R2 Available in Xcode 15.3
    Improving default container formatting P2585R1 Available in Xcode 15.3
    std::ranges::views::repeat P2474R2 Available in Xcode 15.3
    std::mdspan P0009R18 Available in Xcode 15.3
    Formatted output P2093R14 Available in Xcode 15.3
    string_view range constructor should be explicit P2499R0 Requires Xcode 15
    A more constexpr bitset P2417R2 Requires Xcode 15
    forward_like P2445R1 Requires Xcode 15
    Making std::unique_ptr constexpr P2273R3 Requires Xcode 15
    Add constexpr modifiers to functions to_chars and from_chars for integral types in <charconv> header P2291R3 Requires Xcode 15
    std::string::substr() && P2438R2 Requires Xcode 15
    static operator() P1169R4 Requires Xcode 15
    std::expected P0323R12 Requires Xcode 15
    views::as_rvalue P2446R2 Requires Xcode 15
    std::unexpected should have error() as member accessor P2549R1 Requires Xcode 15
    Function to mark unreachable code std::unreachable() P0627R6 Requires Xcode 14.3 or later
    Type trait to detect scoped enumerations std::is_scoped_enum P1048R1
    contains() function for basic_string and basic_string_view P1679R3
    std::to_underlying for enumerations P1682R3
    std::visit() for classes derived from std::variant P2162R2
    Prevent overconstraining allocators in container deduction guides P1518R2
    Prohibit basic_string and basic_string_view construction from nullptr P2166R1
    Require span & basic_string_view to be trivially copyable P2251R1

    C++20

    Feature Paper Notes
    Immediate functions (consteval) P1073R3 Requires Xcode 15
    P1937R2
    Default member initializers for bit-fields P0683R1
    Fix const-qualified (const&-qualified) pointers to members P0704R1
    Allow lambda-capture [=, this] P0409R2
    __VA_OPT__ for comma omission and comma deletion P0306R4
    P1042R1
    Designated initializers P0329R4
    Familiar template-parameter-list syntax for generic lambdas P0428R2
    Concepts P0734R0 Not supported: papers P0857R0, P2113R0, P2103R0, DR1496, DR1734, P0848R3
    P1084R2
    P1141R2
    P1616R1
    P1452R2
    P1972R0
    P1980R0
    P2493R0
    P2092R0
    Range-based for statements with initializer P0614R1
    ADL and function templates that are not visible P0846R0
    const mismatch with defaulted copy constructor P0641R2
    Consistent comparison (operator<=>) P0515R3
    P0905R1
    P1120R0
    P1185R2
    P1186R3
    P1630R1
    P1946R0
    P1959R0
    P2085R0
    Relaxing access checking on specializations P0692R1
    Default constructible and assignable stateless lambdas P0624R2
    Allowing lambdas in unevaluated contexts P0315R4 Not supported: [temp.deduct/9]
    [[no_unique_address]] attribute P0840R2
    [[likely]] and [[unlikely]] attributes P0479R5
    Pack expansion in lambda init-capture P0780R2
    Relaxations of constexpr restrictions P1064R0
    P1002R1
    P1327R1
    P1330R0
    P1331R2
    P1668R1
    P0784R7
    Prohibit aggregates with user-declared constructors P1008R1
    Feature test macros P0941R2
    explicit(bool): conditionally explicit constructor P0892R2
    Signed integers are two's complement P1236R1
    char8_t: A type for UTF-8 characters and strings P0482R6
    std::is_constant_evaluated P0595R2
    Nested inline namespaces P1094R2
    Stronger unicode requirements P1041R4
    P1139R2
    Coroutines P0912R5
    Deprecate comma operator in subscripting expressions like a[b,c] P1161R3
    Deprecate some problematic uses of volatile P1152R4
    [[nodiscard("with reason")]] P1301R4
    using enum P1099R5
    Permit conversions to arrays of unknown bound P0388R4
    constinit P1143R2
    Pseudo-destructors end object lifetimes P0593R6 (DR)
    Implicit move for more local objects and rvalue references P1825R0 (DR)
    Features implemented in the libc++library
    Text formatting (std::format) P0645R10 Available in Xcode 15.3
    Efficient access to basic_stringbuf's buffer P0408R7 Available in Xcode 15.3
    Utility functions to implement uses-allocator construction P0591R4 Requires Xcode 15
    char8_t: A type for UTF-8 characters and strings P0482R6 Requires Xcode 15
    nodiscard in the Library P0600R1 Requires Xcode 15
    polymorphic_allocator<> as a vocabulary type P0339R6 Requires Xcode 15
    Constexpr for std::complex P0415R1 Requires Xcode 15
    Adopt source_location for C++20 P1208R6 Requires Xcode 15
    Input Range Adaptors P1035R7 Requires Xcode 15
    Views should not be required to be default constructible P2325R3 Requires Xcode 15
    Smart pointer creation with default initialization P1020R1 Requires Xcode 15
    Superior String Splitting P2210R2 Requires Xcode 15
    basic_istream_view::iterator should not be copyable P1638R1 Requires Xcode 15
    Output std::chrono::days with ‘d’ suffix P1650R0 Requires Xcode 15
    Ranges adaptors for non-copyable iterators P1862R1 Requires Xcode 15
    Rename “_default_init” Functions, Rev1 P1973R1 Requires Xcode 15
    elements_view needs its own sentinel P1994R1 Requires Xcode 15
    Fix istream_view P2432R1 Requires Xcode 15
    Making std::vector constexpr P1004R2 Requires Xcode 14.3 or later
    Consistent stateful allocator propagation for operator+(basic_string) P1165R1 Requires Xcode 14.3 or later
    Support arrays in make_shared and allocate_shared P0674R1 Requires Xcode 14.3 or later
    Making std::string constexpr P0980R1 Requires Xcode 14.3 or later
    Consider ATOMIC_FLAG_INIT undeprecation LWG3659 Requires Xcode 14.3 or later
    char8_t backward compatibility remediation P1423R3 Requires Xcode 14.3 or later
    Bit-casting object representations P0476R2 Requires Xcode 14.3 or later
    Ranges P0896R4 Requires Xcode 14.3 or later
    P2415R2 Requires Xcode 14.3 or later
    P2281R1 Requires Xcode 14.3 or later
    std::endian P0463R1
    Add constexpr modifiers to functions in <algorithm> and <utility> headers P0202R3
    Make std::memory_order a scoped enumeration P0439R0
    String prefix and suffix checking P0457R2
    Transformation trait remove_cvref P0550R2
    De-pessimize legacy <numeric> algorithms with std::move P0616R0
    Utility to convert a pointer to a raw pointer P0653R2
    Deprecate is_pod P0767R1
    Library support for the spaceship (comparison) operator <=> P0768R1
    Treating unnecessary decay P0777R1
    <span> P0122R7
    Thou shalt not specialize std function templates! P0551R3
    <version> P0754R2
    Comparing unordered containers P0809R0
    Constexpr iterator requirements P0858R0
    string::reserve should not shrink P0966R1
    Checking for existence of an element in associative containers P0458R2
    Guaranteed copy elision for piecewise construction P0475R1
    Integral power-of-2 operations P0556R3
    Reviewing deprecated facilities of C++17 for C++20 P0619R4 Not supported: P0619, Sections D.4, D.7, D.11, D.12, and D.14
    Improving the return value of erase-like algorithms P0646R1
    Efficient sized delete for variable sized classes P0722R3
    Implicit conversion traits and utility functions P0758R1
    fpos requirements P0759R1
    Add shift to <algorithm> P0769R2
    constexpr for swap and swap related functions P0879R0
    The identity metafunction P0887R1
    Standard library concepts P0898R3
    Eradicating unnecessarily explicit default constructors P0935R0
    constexpr comparison operators for std::array P1023R0
    std::unwrap_ref_decay and std::unwrap_reference P0318R1
    Simplified partial function application P0356R5
    Supporting Incomplete types In reference_wrapper P0357R3
    Fixing operator>>(basic_istream&, CharT*) P0487R1
    std::is_constant_evaluated() P0595R2
    Variant and optional should propagate copy/move triviality P0602R4
    Improving variant's Converting Constructor/Assignment P0608R3
    visit<R>: explicit return type for visit P0655R1
    std::function move constructor should be noexcept P0771R1
    Heterogeneous lookup for unordered containers P0919R3
    <chrono> zero(), min(), and max() should be noexcept P0972R0
    constexpr in std::pointer_traits P1006R1
    Misc constexpr bits P1032R1
    Remove comparison operators of std::span P1085R2
    Adopt consistent container erasure from library fundamentals 2 P1209R0
    Remove CommonReference requirement from StrictWeakOrdering P1248R1
    Making std::underlying_type SFINAE-friendly P0340R3
    Well-behaved interpolation for numbers and pointers P0811R3
    Usability enhancements for std::span P1024R3
    Make create_directory() intuitive P1164R1
    signed ssize() functions, unsigned size() functions P1227R2
    Traits for [Un]bounded Arrays P1357R1
    Mandating the standard library: Clause 16 - Language support library P1458R1
    Mandating the standard library Clause 18 - Diagnostics library P1459R1
    Mandating the standard library: Clause 20 - Strings library P1462R1
    Mandating the standard library: Clause 22 - Iterators library P1464R1
    to_array from LFTS with updates P0325R4
    Bit operations P0553R4
    Math constants P0631R8
    More onstexpr containers P0784R7
    constexpr invoke P1065R2
    Synchronization library (<barrier>, <latch>, <semaphore> and notification functions on std::atomic) P1135R6 Minimum deployment target:
    macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0
    Exposing a narrow contract for ceil2 P1355R2
    Relocate endian’s specification P1612R1
    bind_front should not unwrap reference_wrapper P1651R0
    Remove dedicated precalculated hash lookup interface P1661R1
    Fixing atomic initialization P0883R2
    Range constructor for std::string_view P1391R4
    Range constructor for std::span P1394R4
    constexpr for numeric algorithms P1645R1
    Heterogeneous lookup for unordered containers P1690R1
    Add max() to latch and barrier P1865R1 Minimum deployment target:
    macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0
    Concept traits should be named after concepts P1871R1
    span should have size_type, not index_type P1872R0
    Remove std::weak_equality and std::strong_equality P1959R0
    Safe integral comparisons P0586R2
    Improving the return value of erase-like algorithms II: free erase/erase if P1115R3
    On the names of low-level bit manipulation functions P1956R1
    Wording for boolean-testable P1964R2
    Fixed-size span construction from dynamic range P1976R2
    Remove tuple-like protocol support from fixed-extent span P2116R0
    Missing constexpr in std::optional and std::variant P2231R1 Not supported: changes to std::variant

    C++17

    Feature Paper Notes
    static_assert with no message N3928
    Removing trigraphs N4086
    typename in a template template parameter N4051
    New auto rules for direct-list-initialization N3922
    Fold expressions N4295
    P0036R0
    u8 character literals P0036R0
    Nested namespace definition N4230
    Attributes for namespaces and enumerators N4266
    Allow constant evaluation for all non-type template arguments N4268
    Remove deprecated register storage class P0001R1
    Remove deprecated bool increment P0002R1
    Make exception specifications part of the type system P0012R1
    __has_include in preprocessor conditionals P0061R1
    [[fallthrough]] attribute P0188R1
    [[nodiscard]] attribute P0189R1
    P1771R1 (DR)
    [[maybe_unused]] attribute P0212R1
    Aggregate initialization of classes with base classes P0017R1
    constexpr lambda expressions P0170R1
    Differing begin and end types in range-based for P0184R0
    Lambda capture of *this P0018R3
    Direct-list-initialization of enums P0138R2
    Hexadecimal floating-point literals P0245R1
    Using attribute namespaces without repetition P0028R4
    Dynamic memory allocation for over-aligned data P0035R4
    Template argument deduction for class templates P0091R3
    P0512R0
    P0620R0 (DR)
    P0702R1 (DR)
    Non-type template parameters with auto type P0127R2
    Guaranteed copy elision P0135R1
    Stricter expression evaluation order P0145R3
    P0400R0
    Requirement to ignore unknown attributes P0283R2
    constexpr if statements P0292R2
    Inline variables P0386R2
    Structured bindings P0217R3
    P0961R1 (DR)
    P0969R0 (DR)
    Separate variable and condition for if and switch P0305R1
    Matching of template template-parameters to arguments P0522R0 This feature can be source breaking. Should be enabled explicitly with the compiler flag -frelaxed-template-template-args
    Removing deprecated dynamic exception specifications P0003R5
    Features implemented in the libc++library
    <memory_resource> P0220R1

    Requires Xcode 15

    Minimum deployment target: iOS 17.0, macOS 14.0, watchOS 10.0 and tvOS 17.0.

    Filesystem library P0219R1 Minimum deployment target:
    macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0
    P0218R1
    P0392R0
    P0317R1
    P0492R2
    TransformationTrait Alias void_t. N3911
    Invoke function template N4169
    std::uncaught_exceptions N4259
    TriviallyCopyable reference_wrapper. N4277
    Improved insertion interface for unique-key maps. N4279
    std::size(), std::empty() and std::data() N4280
    Contiguous Iterators N4284
    Cleanup for exception-specification and throw-expression. N4285
    Improving std::pair and std::tuple N4387
    bool_constant N4389
    shared_mutex N4508

    Pass -fno-exceptions compiler flag to back deploy to older OSes. Note that methods that throw exceptions on failure will abort in this mode.

    LWG 2228 missing SFINAE rule N4366
    Minimal incomplete type support for standard containers N4510
    Remove deprecated iostreams aliases. P0004R1
    Adopt type traits variable templates for C++17 P0006R0
    Polishing <chrono> P0092R1
    Constant view: std::as_const helper function template. P0007R1
    Making std::owner_less more flexible P0074R0
    Logical type traits rev 2 P0013R1
    Re-enabling shared_from_this P0033R1
    Adopt not_fn from library fundamentals 2 for C++17 P0005R4
    constexpr atomic::is_always_lock_free P0152R1
    [nothrow-]swappable traits P0185R1
    Fixing a design mistake in the searchers interface P0253R1
    An algorithm to clamp a value between a pair of boundary values P0025R0
    3-argument overload to std::hypot P0030R1
    Constexpr modifiers for reverse_iterator, move_iterator, array and Range Access P0031R0
    Give std::string a non-const .data() member function P0272R1
    is_callable, the missing INVOKE related trait P0077R2
    Homogeneous interface for variant, any and optional P0032R3
    Extending memory management tools P0040R3
    C++17 should refer to C11 instead of C99 P0063R3
    Splicing maps and sets P0083R3
    Emplace return type P0084R2
    Variant: a type-safe union for C++17 P0088R3

    Minimum deployment target:
    bad_variant_access and methods that throw it: get and visit require macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0

    Pass -fno-exceptions compiler flag to back deploy to older OSes. Note that methods that throw exceptions on failure will abort in this mode.

    Replacement of class objects containing reference members P0137R1
    shared_ptr::weak_type P0163R0
    Synopses for the c library P0175R1
    Reserve a new library namespace for future standardization P0180R2
    make_from_tuple: apply for construction P0209R2
    Integrating std::string_view and std::string P0254R2
    has_unique_object_representations P0258R2
    Adopt selected library fundamentals V2 components for C++17 P0295R0
    Adopt library fundamentals V1 TS components for C++17 (optional, string_view, any) P0220R1

    Minimum deployment target:
    bad_optional_access and bad_any_cast, and methods that throw them: optional::value and any_cast require macOS 10.13, iOS 12.0, tvOS 12.0, watchOS 5.0

    Pass -fno-exceptions compiler flag to back deploy to older OSes. Note that methods that throw exceptions on failure will abort in this mode.

    Removing allocator support in std::function P0302R1
    Making optional greater equal again P0307R2
    Better names for parallel execution policies in C++17 P0336R1
    Delete operator= for polymorphic_allocator P0337R0
    A <random> nomenclature tweak P0346R1
    Fixes for not_fn P0358R1
    Temporarily discourage memory_order_consume P0371R1
    Making variant greater equal P0393R3
    Removing deprecated exception specifications from C++17 P0003R5
    Elementary string conversions std::to_chars, std::from_chars P0067R5

    Minimum deployment target:
    For integral types, macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0

    For floating-point types, macOS 13.3, iOS 16.3, tvOS 16.3, watchOS 9.3

    Literal suffixes for basic_string_view P0403R1
    Merging shared_ptr changes from Library Fundamentals to C++17 P0414R2
    Constexpr for std::char_traits P0426R1
    Resolving LWG Issues re common_type P0435R1
    Correcting library usage of “literal type” P0503R0
    Revisiting in-place tag types for any/optional/variant P0504R0
    Wording for GB 50 - constexpr for chrono P0505R0
    Updating “Restrictions on exception handling” P0509R1
    Disallowing references, incomplete types, arrays, and empty variants P0510R0
    Poisoning the hash P0513R0
    Clarify that shared_future’s copy operations have wide contracts P0516R0
    Make future_error constructible P0517R0
    shared_ptr use_count/unique P0521R0
    Variadic lock guard(rev 5) P0156R2
    A byte type definition P0298R3
    File system library on non-POSIX-like operating systems P0430R2
    Integrating template deduction for class templates into the standard library P0433R2
    common_type and duration P0548R1
    Resolving atomic<T> named base class inconsistencies P0558R1
    noexcept for hash functions P0599R1
    Resolving GB 55, US 84, US 85, US 86 P0604R0
    Some improvements to class template argument deduction integration into the standard library P0739R0

    C++14

    Feature Paper Notes
    Tweak to certain c++ contextual conversions N3323
    Binary literals N3472
    decltype(auto) N3638
    Return type deduction for normal functions
    Initialized lambda captures N3648
    Generic lambdas N3649
    Variable templates N3651
    Relaxing requirements on constexpr functions N3652
    Member initializers and aggregates N3653
    Clarifying memory allocation N3664
    [[deprecated]] attribute N3760
    Single quotation mark as digit separator N3781
    Sized deallocation (delete and delete[]) N3778
    Features implemented in the libc++library
    Terminology for container element requirements - Rev 1 N3346
    Making operator functors greater<> N3421
    std::result_of and SFINAE N3462
    integral_constant improvements N3545
    Null forward iterators N3644
    std::exchange() N3668
    Compile-time integer sequences N3658
    Addressing tuples by type N3670
    Making non-modifying sequence operations more robust N3671
    make_unique N3656
    Quoted Strings N3654
    User-defined Literals N3642
    TransformationTraits Redux (excluding part 4) N3655
    Heterogeneous comparison lookup N3657
    Fixing constexpr member functions without const N3669
    Shared locking N3659
    User-defined literals for std::complex N3779
    Discouraging rand() N3924
    Consistent metafunction aliases N3887
    Rename shared_mutex to shared_timed_mutex N3891
    Constexpr library additions: chrono, containers, utilities, complex numbers, functional N3469
    N3470
    N3471
    N3302
    N3789

    C++11

    Feature Paper Notes
    Rvalue references N2118
    P1825R0 (DR)
    Rvalue references for *this N2439
    Initialization of class objects by rvalues N1610
    Non-static data member initializers N2756
    Variadic templates N2242
    Extending variadic template template parameters N2555
    Initializer lists N2672
    P1009R2 (DR)
    P1957R2 (DR)
    Static assertions N1720
    auto-typed variables N1984
    Multi-declarator auto N1737
    Removal of auto as a storage-class specifier N2546
    New function declarator syntax N2541
    Declared type of an expression N2343
    Incomplete return types N3276
    Right angle brackets N1757
    Default template arguments for function templates DR226
    Solving the SFINAE problem for expressions DR339
    Alias templates N2258
    Extern templates N1987
    Null pointer constant N2431
    Strongly-typed enums N2347
    Forward declarations for enums N2764
    DR1206
    Standardized attribute syntax N2761
    ConstExpr: generalized constant expressions N2235
    P0859R0 (DR)
    Alignment support N2341
    Conditionally-support behavior N1627
    Changing undefined behavior into diagnosable errors N1727
    Delegating constructors N1986
    Inheriting constructors N2540
    P0136R1 (DR)
    Explicit conversion operators N2437
    New character types N2249
    Unicode string literals N2442
    Raw string literals N2442
    Universal character names in literals N2170
    User-defined literals N2765
    Standard Layout Types N2342
    Defaulted functions N2346
    P1286R2 (DR)
    Deleted functions N2346
    Extended friend declarations N1791
    Extending sizeof N2253
    DR850
    Inline namespaces N2535
    Unrestricted unions N2544
    Local and unnamed types as template arguments N2657
    Range-based for N2930
    P0962R1 (DR)
    Explicit virtual overrides N2928
    N3206
    N3272
    Allowing move constructors to throw [noexcept] N3050
    Defining move special member functions N3053
    Concurrency
    Sequence points N2239
    Atomic operations N2427
    Strong compare and exchange N2748
    Bidirectional fences N2752
    Memory model N2429
    Data-dependency ordering: atomics and memory model N2664
    Propagating exceptions N2179
    Allow atomics use in signal handlers N2547
    Thread-local storage N2659
    Dynamic initialization and destruction with concurrency N2660
    C99 Features in C++11
    __func__ predefined identifier N2340
    C99 preprocessor N1653
    long long N1811

    C++98/03

    Clang and libc++ supports all features of the ISO C++ 1998 standard and the defects addressed in the ISO C++ 2003 standard.