C++ 2017 ISO C++ 2017 In this implementation the -std=gnu++17 or -std=c++17 flag must be used to enable language and library features. See dialect options. The pre-defined symbol __cplusplus is used to check for the presence of the required flag. GCC 9.1 was the first release with non-experimental C++17 support, so the API and ABI of features added in C++17 is only stable since that release. This section describes the C++17 and library TS support in the GCC 10 release series. The following table lists new library features that are included in the C++17 standard. The "Proposal" column provides a link to the ISO C++ committee proposal that describes the feature, while the "Status" column indicates the first version of GCC that contains an implementation of this feature (if it has been implemented). The "SD-6 Feature Test" column shows the corresponding macro or header from SD-6: Feature-testing recommendations for C++. C++ 2017 Library Features Library Feature Proposal Status SD-6 Feature Test constexpr std::hardware_{constructive,destructive}_interference_size P0154R1 No __cpp_lib_hardware_interference_size >= 201603 Core Issue 1776: Replacement of class objects containing reference members P0137R1 7.1 __cpp_lib_launder >= 201606 Wording for std::uncaught_exceptions N4259 6.1 __cpp_lib_uncaught_exceptions >= 201411 C++17 should refer to C11 instead of C99 P0063R3 9.1 Variant: a type-safe union for C++17 P0088R3 7.1 __has_include(<variant>), __cpp_lib_variant >= 201603 (since 7.3, see Note 1) Library Fundamentals V1 TS Components: optional P0220R1 7.1 __has_include(<optional>), __cpp_lib_optional >= 201603 (since 7.3, see Note 1) Library Fundamentals V1 TS Components: any P0220R1 7.1 __has_include(<any>), __cpp_lib_any >= 201603 (since 7.3, see Note 1) Library Fundamentals V1 TS Components: string_view P0220R1 7.1 __has_include(<string_view>), __cpp_lib_string_view >= 201603 (since 7.3, see Note 1) Library Fundamentals V1 TS Components: memory_resource P0220R1 9.1 __has_include(<memory_resource>), __cpp_lib_memory_resource >= 201603 Library Fundamentals V1 TS Components: apply P0220R1 7.1 __cpp_lib_apply >= 201603 Library Fundamentals V1 TS Components: shared_ptr<T[]> P0220R1 7.1 __cpp_lib_shared_ptr_arrays >= 201603 Library Fundamentals V1 TS Components: Searchers P0220R1 7.1 __cpp_lib_boyer_moore_searcher >= 201603 Library Fundamentals V1 TS Components: Sampling P0220R1 7.1 __cpp_lib_sample >= 201603 Constant View: A proposal for a std::as_const helper function template P0007R1 7.1 __cpp_lib_as_const >= 201510 Improving pair and tuple N4387 6.1 N/A make_from_tuple: apply for construction P0209R2 7.1 __cpp_lib_make_from_tuple >= 201606 Removing auto_ptr, random_shuffle(), And Old <functional> Stuff N4190 No (kept for backwards compatibility) Deprecating Vestigial Library Parts in C++17 P0174R2 No (kept for backwards compatibility) Making std::owner_less more flexible P0074R0 7.1 __cpp_lib_transparent_operators >= 201510 std::addressof should be constexpr LWG2296 7.1 __cpp_lib_addressof_constexpr >= 201603 Safe conversions in unique_ptr<T[]> N4089 6 LWG 2228: Missing SFINAE rule in unique_ptr templated assignment N4366 6 Re-enabling shared_from_this P0033R1 7.1 __cpp_lib_enable_shared_from_this >= 201603 A proposal to add invoke function template N4169 6.1 __cpp_lib_invoke >= 201411 TriviallyCopyable reference_wrapper N4277 5.1 Adopt not_fn from Library Fundamentals 2 for C++17 P0005R4 7.1 __cpp_lib_not_fn >= 201603 Fixes for not_fn P0358R1 7.1 Fixing a design mistake in the searchers interface in Library Fundamentals P0253R1 7.1 Extending memory management tools P0040R3 7.1 __cpp_lib_raw_memory_algorithms >= 201606L shared_ptr::weak_type P0163R0 7.1 __cpp_lib_shared_ptr_weak_type >= 201606 Transformation Trait Alias void_t N3911 6.1 __cpp_lib_void_t >= 201411 Wording for bool_constant, revision 1 N4389 6.1 __cpp_lib_bool_constant >= 201505 Adopt Type Traits Variable Templates from Library Fundamentals TS for C++17 P0006R0 7.1 __cpp_lib_type_trait_variable_templates >= 201510 Logical Operator Type Traits P0013R1 6.1 __cpp_lib_logical_traits >= 201510 Adding [nothrow-]swappable traits P0185R1 7 (__is_swappable available since 6.1) __cpp_lib_is_swappable >= 201603 is_callable, the missing INVOKE related trait P0077R2 7.1 __cpp_lib_is_invocable >= 201703 has_unique_object_representations P0258R2 7.1 __cpp_lib_has_unique_object_representations >= 201606 Polishing <chrono> P0092R1 7.1 __cpp_lib_chrono >= 201510 Adding more constexpr to <chrono> P0505R0 7.1 __cpp_lib_chrono >= 201611 (since 7.3, see Note 2) Constexpr for std::char_traits P0426R1 8.1 __cpp_lib_constexpr_char_traits >= 201611 Integrating std::string_view and std::string P0254R2 7.1 Give 'std::string' a non-const '.data()' member function P0272R1 7.1 Cleaning-up noexcept in the Library N4258 6.1 __cpp_lib_allocator_traits_is_always_equal >= 201411 Contiguous Iterators N4284 N/A Minimal incomplete type support for standard containers N4510 3.0 __cpp_lib_incomplete_container_elements >= 201505 (since 6.2, see Note 2) Emplace return type P0084R2 7.1 Improved insertion interface for unique-key maps N4279 6.1 __cpp_lib_map_try_emplace >= 201411, __cpp_lib_unordered_map_try_emplace >= 201411 Splicing Maps and Sets P0083R3 7.1 __cpp_lib_node_extract >= 201606 Non-member size() and more N4280 6.1 __cpp_lib_nonmember_container_access >= 201411 A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access P0031R0 7.1 __cpp_lib_array_constexpr >= 201603 The Parallelism TS Should be Standardized P0024R2 9.1 __has_include(<execution>) , __cpp_lib_execution >= 201603 , __cpp_lib_parallel_algorithm >= 201603 (requires linking with -ltbb, see Note 3) An algorithm to "clamp" a value between a pair of boundary values P0025R0 7.1 __cpp_lib_clamp >= 201603 Adopt Selected Library Fundamentals V2 Components for C++17 P0295R0 7.1 __cpp_lib_gcd_lcm >= 201606 Proposal to Introduce a 3-Argument Overload to std::hypot P0030R1 7.1 __cpp_lib_hypot >= 201603 Mathematical Special Functions for C++17 P0226R1 7.1 __cpp_lib_math_special_functions >= 201603 (see Note 4) Adopt the File System TS for C++17 P0218R1 8.1 __has_include(<filesystem>) , __cpp_lib_filesystem >= 201603 (GCC 8.x requires linking with -lstdc++fs) Relative Paths for Filesystem P0219R1 8.1 __cpp_lib_filesystem >= 201606 Adapting string_view by filesystem paths P0392R0 8.1 __cpp_lib_filesystem >= 201606 Directory Entry Caching for Filesystem P0317R1 8.1 __cpp_lib_filesystem >= 201703 constexpr atomic<T>::is_always_lock_free P0152R1 7.1 __cpp_lib_atomic_is_always_lock_free >= 201603 A proposal to add shared_mutex (untimed) (Revision 4) N4508 6.1 __cpp_lib_shared_mutex >= 201505 Variadic lock_guard (Rev. 5) P0156R2 7.1 __cpp_lib_scoped_lock >= 201703 A byte type definition P0298R3 7.1 __cpp_lib_byte >= 201603 (since 7.3, see Note 2) Elementary string conversions P0067R5 8.1 (only integral types supported) __has_include(<charconv>) __cpp_lib_to_chars >= 201611 Homogeneous interface for variant, any and optional P0032R3 7.1 __cpp_lib_any >= 201606 , __cpp_lib_optional >= 201606 , __cpp_lib_variant >= 201606 Making Optional Greater Equal Again P0307R2 7.1 __cpp_lib_optional >= 201606
Note 1: This feature is supported in GCC 7.1 and 7.2 but before GCC 7.3 the __cpp_lib macro is not defined, and compilation will fail if the header is included without using to enable C++17 support. Note 2: This feature is supported in older releases but the __cpp_lib macro is not defined to the right value (or not defined at all) until the version shown in parentheses. Note 3: The Parallel Algorithms have an external dependency on Intel TBB 2018 or later. If the <execution> header is included then -ltbb must be used to link to TBB. Note 4: The mathematical special functions are enabled in C++17 mode from GCC 7.1 onwards. For GCC 6.x or for C++11/C++14 define __STDCPP_WANT_MATH_SPEC_FUNCS__ to a non-zero value and test for __STDCPP_MATH_SPEC_FUNCS__ >= 201003L. The following status table is based on the table of contents of ISO/IEC 14882:2017. Some subclauses are not shown in the table where the content is unchanged since C++14 and the implementation is complete. C++ 2017 Implementation Status Section Description Status Comments 21 Language support 21.1 General 21.2 Common definitions 21.3 Implementation properties 21.3.1 General 21.3.2 Header <limits> synopsis 21.3.3 Floating-point type properties 21.3.3.1 float_round_style N 21.3.3.2 float_denorm_style N 21.3.4 Class template numeric_limits Y 21.3.5 Header <climits> synopsis Y 21.3.6 Header <cfloat> synopsis Y 21.4 Integer types 21.4.1 Header <cstdint> synopsis Y 21.5 Start and termination Partial C library dependency for quick_exit, at_quick_exit 21.6 Dynamic memory management 21.6.1 Header <new> synopsis 21.6.2 Storage allocation and deallocation Y 21.6.3 Storage allocation errors Y 21.6.4 Pointer optimization barrier Y 21.6.5 Hardware interference size N 21.7 Type identification Y 21.8 Exception handling 21.8.1 Header <exception> synopsis 21.8.2 Class exception Y 21.8.3 Class bad_exception Y 21.8.4 Abnormal termination Y 21.8.5 uncaught_exceptions Y 21.8.6 Exception Propagation Y 21.8.7 nested_exception Y 21.9 Initializer lists Y 21.10 Other runtime support Y 22 Diagnostics 22.1 General 22.2 Exception classes Y 22.3 Assertions Y 22.4 Error numbers Y 22.5 System error support 23 General utilities 23.1 General 23.2 Utility components 23.2.1 Header <utility> synopsis 23.2.2 Operators Y 23.2.3 swap Y 23.2.4 exchange Y 23.2.5 Forward/move helpers Y 23.2.6 Function template as_const Y 23.2.7 Function template declval Y 23.2.8 Primitive numeric output conversion Partial Only integer types supported, not floating-point types 23.2.9 Primitive numeric input conversion Partial Only integer types supported, not floating-point types 23.3 Compile-time integer sequences 23.4 Pairs Y 23.5 Tuples Y 23.6 Optional objects Y 23.7 Variants Y 23.8 Storage for any type Y 23.9 Bitsets Y 23.10 Memory Y 23.10.1 In general 23.10.2 Header <memory> synopsis Y 23.10.3 Pointer traits Y 23.10.4 Pointer safety Y 23.10.5 Align Y 23.10.6 Allocator argument tag Y 23.10.7 uses_allocator Y 23.10.8 Allocator traits Y 23.10.9 The default allocator Y 23.10.10 Specialized algorithms Y 23.10.11 C library memory allocation Y 23.11 Smart pointers 23.11.1 Class template unique_ptr Y 23.11.2 Shared-ownership pointers Y 23.12 Memory resources 23.12.1 Header <memory_resource> synopsis Y 23.12.2 Class memory_resource Y 23.12.3 Class template polymorphic_allocator Y 23.12.4 Access to program-wide memory_resource objects Y 23.12.5 Pool resource classes Y 23.12.6 Class monotonic_buffer_resource Y 23.13 Class template scoped_allocator_adaptor Y 23.14 Function objects 23.14.1 Header <functional> synopsis 23.14.2 Definitions 23.14.3 Requirements 23.14.4 Function template invoke Y 23.14.5 Class template reference_wrapper Y 23.14.6 Arithmetic operation Y 23.14.7 Comparisons Y 23.14.8 Logical operations Y 23.14.9 Bitwise operations Y 23.14.10 Function template not_fn Y 23.14.11 Function object binders Y 23.14.12 Function template mem_fn Y 23.14.13 Polymorphic function wrappers Y 23.14.14 Searchers Y 23.14.15 Class template hash Y 23.15 Metaprogramming and type traits 23.15.1 Requirements 23.15.2 Header <type_traits> synopsis Y 23.15.3 Helper classes Y 23.15.4 Unary Type Traits Y 23.15.5 Type property queries Y 23.15.6 Relationships between types Y 23.15.7 Transformations between types Y 23.15.8 Logical operator traits Y 23.16 Compile-time rational arithmetic Y 23.17.1 In general 23.17.2 Header <chrono> synopsis 23.17 Time utilities 23.17.3 Clock requirements Y 23.17.4 Time-related traits Y 23.17.5 Class template duration Y 23.17.6 Class template time_point Y 23.17.7 Clocks Y 23.17.8 Header <ctime> synopsis Y 23.18 Class type_index Y 23.19 Execution policies 23.19.1 In general 23.19.2 Header <execution> synopsis 23.19.3 Execution policy type trait Y 23.19.4 Sequenced execution policy Y 23.19.5 Parallel execution policy Y 23.19.6 Parallel and unsequenced execution policy Y 23.19.7 Execution policy objects Y 24 Strings 24.1 General 24.2 Character traits Y 24.3 String classes Y 24.4 String view classes Y 24.4.1 Header <string_view> synopsis Y 24.4.2 Class template basic_string_view Y 24.4.3 Non-member comparison functions Y 24.4.4 Inserters and extractors Y 24.4.5 Hash support Y 24.4.6 Suffix for basic_string_view literals Y 24.5 Null-terminated sequence utilities Partial C library dependency. 25 Localization 25.1 General Y 25.2 Header <locale> synopsis Y 25.3 Locales Y 25.4 Standard locale categories Y 25.5 C Library Locales Y 26 Containers 26.1 General 26.2 Container requirements Y 26.3 Sequence containers Y 26.4 Associative containers Y 26.5 Unordered associative containers Y 26.6 Container adaptors Y 27 Iterators 27.1 General Y 27.2 Iterator requirements Y 27.3 Header <iterator> synopsis Y 27.4 Iterator primitives Y 27.5 Iterator adaptors Y 27.6 Stream iterators Y 27.7 Range access Y 27.8 Container access Y 28 Algorithms 28.1 General 28.2 Header <algorithm> synopsis 28.3 Algorithms requirements 28.4 Parallel algorithms Using PSTL 28.5 Non-modifying sequence operations Y 28.6 Mutating sequence operations Y 28.7 Sorting and related operations Y 28.8 C library algorithms Y 29 Numerics 29.1 General 29.2 Definitions 29.3 Numeric type requirements Y 29.4 The floating-point environment Y 29.5 Complex numbers Y 29.6 Random number generation Y 29.7 Numeric arrays Y 29.8 Generalized numeric operations 29.8.1 Header <numeric> synopsis 29.8.2 Accumulate Y 29.8.3 Reduce Y 29.8.4 Inner product Y 29.8.5 Transform reduce Y 29.8.6 Partial sum Y 29.8.7 Exclusive scan Y 29.8.8 Inclusive scan Y 29.8.9 Transform exclusive scan Y 29.8.10 Transform inclusive scan Y 29.8.11 Adjacent difference Y 29.8.12 Iota Y 29.8.13 Greatest common divisor Y 29.8.14 Least common multiple Y 29.9 Mathematical functions for floating-point types 29.9.1 Header <cmath> synopsis 29.9.2 Absolute values Y 29.9.3 Three-dimensional hypotenuse Y 29.9.4 Classification / comparison functions Y 29.9.5 Mathematical special functions Y 30 Input/output library 30.1 General Y 30.2 Iostreams requirements Y 30.2.1 Imbue Limitations Y 30.2.2 Positioning Type Limitations Y 30.2.3 Thread safety Partial 30.3 Forward declarations Y 30.4 Standard iostream objects Y 30.5 Iostreams base classes Y 30.6 Stream buffers Y 30.7 Formatting and manipulators Y 30.8 String-based streams Y 30.9 File-based streams Y 30.10 File systemss Y 30.11 C library files Y 31 Regular expressions 31.1 General Y 31.2 Definitions Y 31.3 Requirements Y 31.4 Header <regex> synopsis Y 31.5 Namespace std::regex_constants Y 31.6 Class regex_error Y 31.7 Class template regex_traits Partial transform_primary is not correctly implemented 31.8 Class template basic_regex Y 31.9 Class template sub_match Y 31.10 Class template match_results Y 31.11 Regular expression algorithms Y 31.12 Regular expression Iterators Y 31.13 Modified ECMAScript regular expression grammar Y 32 Atomic operations 32.1 General Y 32.2 Header <atomic> synopsis Y 32.3 Type aliases Y 32.4 Order and consistency Y 32.5 Lock-free property Y 32.6 Class template <atomic> Y 32.7 Non-member functions Y 32.8 Flag Type and operations Y 32.9 Fences Y 33 Thread support 33.1 General Y 33.2 Requirements Y 33.3 Threads 33.3.1 Header thread synopsis 33.3.2 Class thread Y 33.3.2.1 Class thread Partial thread::id comparisons not well-defined 33.3.3 Namespace this_thread Y 33.4 Mutual exclusion 33.4.3 Mutex requirements 33.4.3.1 In general 33.4.3.2 Mutex types 33.4.3.2.1 Class mutex Y 33.4.3.2.2 Class recursive_mutex Y 33.4.3.3 Timed mutex types 33.4.3.3.1 Class timed_mutex Y 33.4.3.3.2 Class recursive_timed_mutex Y 33.4.3.4 Shared mutex types 33.4.3.4.1 Class shared_mutex Y 33.4.3.5 Shared timed mutex types 33.4.3.5.1 Class shared_timed_mutex Y 33.4.4 Locks 33.4.4.1 Class template lock_guard Y 33.4.4.2 Class template scoped_guard Y 33.4.4.3 Class template unique_lock Y 33.4.4.4 Class template shared_lock Y 33.4.5 Generic locking algorithms Y 33.4.6 Call once 33.4.6.1 Struct once_flag Y 33.4.6.2 Function call_once Broken See PR 66146 33.5 Condition variables Y 33.5.1 Class condition_variable Y 33.5.2 Class condition_variable_any Y 33.6 Futures 33.6.1 Overview 33.6.2 Header <future> 33.6.3 Error handling Y 33.6.4 Class future_error Y 33.6.5 Shared state Y 33.6.6 Class template promise Y 33.6.7 Class template future Y 33.6.8 Class template shared_future Y 33.6.9 Function template async Y 33.6.10 Class template packaged_task Y Appendix D Compatibility features D.4 C++ standard library headers Y D.4.1 Header <ccomplex> synopsis Y D.4.1 Header <cstdalign> synopsis Y D.4.1 Header <cstdbool> synopsis Y D.4.1 Header <ctgmath> synopsis Y D.5 C standard library headers Y D.6 char* streams Y D.7 uncaught_exception Y D.8 Old adaptable function bindings Y D.9 The default allocator Y D.10 Raw storage iterator Y D.11 Temporary buffers Y D.12 Deprecated type traits Y D.13 Deprecated iterator primitives Y D.14 Deprecated shared_ptr observers Y D.15 Deprecated standard code conversion facets Y D.16 Deprecated convenience conversion interfaces Y
C++ Technical Specifications Implementation Status Paper Title Status Comments N4076 A generalized callable negator Y Library Fundamentals 2 TS N4273 Uniform Container Erasure Y Library Fundamentals 2 TS N4061 Greatest Common Divisor and Least Common Multiple Y Library Fundamentals 2 TS N4066 Delimited iterators Y Library Fundamentals 2 TS N4282 The World's Dumbest Smart Pointer Y Library Fundamentals 2 TS N4388 Const-Propagating Wrapper Y Library Fundamentals 2 TS N4391 make_array, revision 4 Y Library Fundamentals 2 TS N4502 Support for the C++ Detection Idiom, V2 Y Library Fundamentals 2 TS N4519 Source-Code Information Capture Y Library Fundamentals 2 TS N4521 Merge Fundamentals V1 into V2 N (components from V1 are still in namespace fundamentals_v1) Library Fundamentals 2 TS P0013R1 Logical Operator Type Traits (revision 1) Y Library Fundamentals 2 TS N4531 std::rand replacement, revision 3 Y Library Fundamentals 2 TS
Implementation Specific Behavior For behaviour which is also specified by previous standards, see C++ 1998/2003 Implementation Specific Behavior and C++ 2011 Implementation Specific Behavior. This section only documents behaviour which is new in the 2017 standard. 20.5.1.2 [headers] Whether names from Annex K are declared by C++ headers depends on whether the underlying C library supports Annex K and declares the names. For the GNU C library, there is no Annex K support and so none of its names are declared by C++ headers. 23.6.5 [optional.bad_optional_access] what() returns "bad optional access". 23.7.3 [variant.variant] variant supports over-aligned types. 23.7.10 [variant.bad.access] what() returns one of the strings "std::get: variant is valueless", "std::get: wrong index for variant", "std::visit: variant is valueless", or "std::visit<R>: variant is valueless". 23.12.5.2 [memory.resource.pool.options] Let S equal numeric_limits<size_t>::digits. The limit for maximum number of blocks in a chunk is given by 2N-1, where N is min(19, 3 + S/2). The largest allocation size that will be allocated from a pool is 222 when S > 20, otherwise 3072 when S > 16, otherwise 768. 23.12.6.1 [memory.resource.monotonic.buffer.ctor] The default next_buffer_size is 128 * sizeof(void*). The default growth factor is 1.5. 23.15.4.3 [meta.unary.prop] The predicate condition for has_unique_object_representations is true for all scalar types except floating point types. 23.19.3 [execpol.type], 28.4.3 [algorithms.parallel.exec] There are no implementation-defined execution policies. 24.4.2 [string.view.template] basic_string_view<C, T>::iterator is C* and basic_string_view<C, T>::const_iterator is const C*. 28.4.3 [algorithms.parallel.exec] Threads of execution created by std::thread provide concurrent forward progress guarantees, so threads of execution implicitly created by the library will provide parallel forward progress guarantees. 29.4.1 [cfenv.syn] The effects of the <cfenv> functions depends on whether the FENV_ACCESS pragma is supported, and on the C library that provides the header. 29.6.9 [c.math.rand] Whether the rand function may introduce data races depends on the target C library that provides the function. 29.9.5 [sf.cmath] The effect of calling the mathematical special functions with large inputs should be documented here. 30.10.2.1 [fs.conform.9945] The behavior of the filesystem library implementation will depend on the target operating system. Some features will not be supported on some targets. Symbolic links and file permissions are not supported on Windows. 30.10.5 [fs.filesystem.syn] The clock used for file times is an unspecified type with a signed 64-bit representation, capable of representing timestamps with nanosecond resolution. The clock's epoch is unspecified, but is not the same as the system clock's epoch. 30.10.7.1 [fs.path.generic] dot-dot in the root-directory refers to the root-directory itself. On Windows, a drive specifier such as "C:" or "z:" is treated as a root-name. On Cygwin, a path that begins with two successive directory separators is a root-name. Otherwise (for POSIX-like systems other than Cygwin), the implementation-defined root-name is an unspecified string which does not appear in any pathnames. 30.10.10.1 [fs.enum.path.format] The character sequence is always interpreted in the native pathname format. 30.10.15.4 [fs.op.file_size] If !is_regular_file(p), an error is reported. 30.10.15.32 [fs.op.rename] On Windows, filesystem::rename is implemented by calling MoveFileExW and so does not meet the requirements of POSIX rename when one or both of the paths resolves to an existing directory. Specifically, it is not possible to rename a directory to replace another directory (POSIX requires that to work if the directory being replaced is empty).