Skip to content

Commit 7f148c3

Browse files
authored
Merge 2018-06 CWG Motion 15
Fixes #2127
2 parents c0fec2c + 0a7e35c commit 7f148c3

File tree

3 files changed

+302
-9
lines changed

3 files changed

+302
-9
lines changed

source/macros.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
\newcommand{\idxcode}[1]{#1@\tcode{#1}}
166166
\newcommand{\idxhdr}[1]{#1@\tcode{<#1>}}
167167
\newcommand{\idxgram}[1]{#1@\gterm{#1}}
168+
\newcommand{\idxxname}[1]{__#1@\xname{#1}}
168169

169170
% class member library index
170171
\newcommand{\indexlibrarymember}[2]{\indexlibrary{\idxcode{#1}!\idxcode{#2}}\indexlibrary{\idxcode{#2}!\idxcode{#1}}}
@@ -189,6 +190,8 @@
189190
\newcommand{\grammartermnc}[1]{\indexgram{\idxgram{#1}}\gterm{#1}\nocorr}
190191
\newcommand{\placeholder}[1]{\textit{#1}}
191192
\newcommand{\placeholdernc}[1]{\textit{#1\nocorr}}
193+
\newcommand{\defnxname}[1]{\indextext{\idxxname{#1}}\xname{#1}}
194+
\newcommand{\defnlibxname}[1]{\indexlibrary{\idxxname{#1}}\xname{#1}}
192195

193196
%%--------------------------------------------------
194197
%% allow line break if needed for justification

source/preprocessor.tex

Lines changed: 139 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
h-pp-tokens h-preprocessing-token
206206
\end{bnf}
207207

208-
\indextext{__HAS_INCLUDE@\xname{has_include}}%
208+
\indextext{\idxxname{has_include}}%
209209
\begin{bnf}
210210
\nontermdef{has-include-expression}\br
211211
\terminal{\xname{has_include} ( <} h-char-sequence \terminal{> )}\br
@@ -214,6 +214,12 @@
214214
\terminal{\xname{has_include} ( <} h-pp-tokens \terminal{> )}
215215
\end{bnf}
216216

217+
\indextext{\idxxname{has_cpp_attribute}}%
218+
\begin{bnf}
219+
\nontermdef{has-attribute-expression}\br
220+
\terminal{\xname{has_cpp_attribute} (} pp-tokens \terminal{)}
221+
\end{bnf}
222+
217223
\pnum
218224
The expression that controls conditional inclusion
219225
shall be an integral constant expression except that
@@ -224,7 +230,8 @@
224230
all identifiers either are or are not macro names ---
225231
there simply are no keywords, enumeration constants, etc.}
226232
and it may contain zero or more \grammarterm{defined-macro-expression}{s} and/or
227-
\grammarterm{has-include-expression}{s} as unary operator expressions.
233+
\grammarterm{has-include-expression}{s} and/or
234+
\grammarterm{has-attribute-expression}{s} as unary operator expressions.
228235

229236
\pnum
230237
A \grammarterm{defined-macro-expression} evaluates to \tcode{1}
@@ -256,12 +263,53 @@
256263
to \tcode{1} if the search for the source file succeeds, and
257264
to \tcode{0} if the search fails.
258265

266+
\pnum
267+
Each \grammarterm{has-attribute-expression} is replaced by
268+
a non-zero \grammarterm{pp-number}
269+
matching the form of an \grammarterm{integer-literal}
270+
if the implementation supports an attribute
271+
with the name specified by interpreting
272+
the \grammarterm{pp-tokens} as an \grammarterm{attribute-token},
273+
and by \tcode{0} otherwise.
274+
The program is ill-formed if the \grammarterm{pp-tokens}
275+
do not match the form of an \grammarterm{attribute-token}.
276+
277+
\pnum
278+
For an attribute specified in this document,
279+
the value of the \grammarterm{has-attribute-expression}
280+
is given by \tref{cpp.cond.ha}.
281+
For other attributes recognized by the implementation,
282+
the value is
283+
\impldef{value of \grammarterm{has-attribute-expression}
284+
for non-standard attributes}.
285+
\begin{note}
286+
It is expected
287+
that the availability of an attribute can be detected by any non-zero result.
288+
\end{note}
289+
290+
\begin{floattable}{\xname{has_cpp_attribute} values}{tab:cpp.cond.ha}
291+
{ll}
292+
\topline
293+
\lhdr{Attribute} & \rhdr{Value} \\ \rowsep
294+
295+
\tcode{carries_depencency} & \tcode{200809L} \\
296+
\tcode{deprecated} & \tcode{201309L} \\
297+
\tcode{fallthrough} & \tcode{201603L} \\
298+
\tcode{likely} & \tcode{201803L} \\
299+
\tcode{maybe_unused} & \tcode{201603L} \\
300+
\tcode{no_unique_address} & \tcode{201803L} \\
301+
\tcode{nodiscard} & \tcode{201603L} \\
302+
\tcode{noreturn} & \tcode{200809L} \\
303+
\tcode{unlikely} & \tcode{201803L} \\
304+
\end{floattable}
305+
259306
\pnum
260307
The \tcode{\#ifdef} and \tcode{\#ifndef} directives, and
261308
the \tcode{defined} conditional inclusion operator,
262-
shall treat \xname{has_include} as if it were the name of a defined macro.
263-
The identifier \xname{has_include} shall not appear
264-
in any context not mentioned in this subclause.
309+
shall treat \xname{has_include} and \xname{has_cpp_attribute}
310+
as if they were the names of defined macros.
311+
The identifiers \xname{has_include} and \xname{has_cpp_attribute}
312+
shall not appear in any context not mentioned in this subclause.
265313

266314
\pnum
267315
Each preprocessing token that remains (in the list of preprocessing tokens that
@@ -417,24 +465,44 @@
417465
comments may appear anywhere in a source file,
418466
including within a preprocessing directive.}
419467

468+
\pnum
420469
\begin{example}
421470
This demonstrates a way to include a library \tcode{optional} facility
422471
only if it is available:
423472

424473
\begin{codeblock}
425474
#if __has_include(<optional>)
426475
# include <optional>
427-
# define have_optional 1
476+
# if __cpp_lib_optional >= 201603
477+
# define have_optional 1
478+
# endif
428479
#elif __has_include(<experimental/optional>)
429480
# include <experimental/optional>
430-
# define have_optional 1
431-
# define experimental_optional 1
432-
#else
481+
# if __cpp_lib_experimental_optional >= 201411
482+
# define have_optional 1
483+
# define experimental_optional 1
484+
# endif
485+
#endif
486+
#ifndef have_optional
433487
# define have_optional 0
434488
#endif
435489
\end{codeblock}
436490
\end{example}
437491

492+
\pnum
493+
\begin{example}
494+
This demonstrates a way to use the attribute \tcode{[[acme::deprecated]]}
495+
only if it is available.
496+
\begin{codeblock}
497+
#if __has_cpp_attribute(acme::deprecated)
498+
# define ATTR_DEPRECATED(msg) [[acme::deprecated(msg)]]
499+
#else
500+
# define ATTR_DEPRECATED(msg) [[deprecated(msg)]]
501+
#endif
502+
ATTR_DEPRECATED("This function is deprecated") void anvil();
503+
\end{codeblock}
504+
\end{example}
505+
438506
\rSec1[cpp.include]{Source file inclusion}
439507
\indextext{preprocessing directive!header inclusion}
440508
\indextext{preprocessing directive!source-file inclusion}
@@ -1381,8 +1449,70 @@
13811449
function.
13821450
If the time of translation is not available,
13831451
an \impldef{text of \mname{TIME} when time of translation is not available} valid time shall be supplied.
1452+
1453+
\item The names listed in \tref{cpp.predefined.ft}.\\
1454+
The macros defined in \tref{cpp.predefined.ft} shall be defined to
1455+
the corresponding integer literal.
1456+
\begin{note}
1457+
Future versions of this International Standard might replace
1458+
the values of these macros with greater values.
1459+
\end{note}
13841460
\end{description}
13851461

1462+
\begin{LongTable}{Feature-test macros}{tab:cpp.predefined.ft}{ll}
1463+
\\ \topline
1464+
\lhdr{Macro name} & \rhdr{Value} \\ \capsep
1465+
\endfirsthead
1466+
\continuedcaption \\
1467+
\hline
1468+
\lhdr{Name} & \rhdr{Value} \\ \capsep
1469+
\endhead
1470+
\defnxname{cpp_aggregate_bases} & \tcode{201603L} \\ \rowsep
1471+
\defnxname{cpp_aggregate_nsdmi} & \tcode{201304L} \\ \rowsep
1472+
\defnxname{cpp_alias_templates} & \tcode{200704L} \\ \rowsep
1473+
\defnxname{cpp_aligned_new} & \tcode{201606L} \\ \rowsep
1474+
\defnxname{cpp_attributes} & \tcode{200809L} \\ \rowsep
1475+
\defnxname{cpp_binary_literals} & \tcode{201304L} \\ \rowsep
1476+
\defnxname{cpp_capture_star_this} & \tcode{201603L} \\ \rowsep
1477+
\defnxname{cpp_constexpr} & \tcode{201603L} \\ \rowsep
1478+
\defnxname{cpp_decltype} & \tcode{200707L} \\ \rowsep
1479+
\defnxname{cpp_decltype_auto} & \tcode{201304L} \\ \rowsep
1480+
\defnxname{cpp_deduction_guides} & \tcode{201703L} \\ \rowsep
1481+
\defnxname{cpp_delegating_constructors} & \tcode{200604L} \\ \rowsep
1482+
\defnxname{cpp_enumerator_attributes} & \tcode{201411L} \\ \rowsep
1483+
\defnxname{cpp_fold_expressions} & \tcode{201603L} \\ \rowsep
1484+
\defnxname{cpp_generic_lambdas} & \tcode{201304L} \\ \rowsep
1485+
\defnxname{cpp_guaranteed_copy_elision} & \tcode{201606L} \\ \rowsep
1486+
\defnxname{cpp_hex_float} & \tcode{201603L} \\ \rowsep
1487+
\defnxname{cpp_if_constexpr} & \tcode{201606L} \\ \rowsep
1488+
\defnxname{cpp_inheriting_constructors} & \tcode{201511L} \\ \rowsep
1489+
\defnxname{cpp_init_captures} & \tcode{201304L} \\ \rowsep
1490+
\defnxname{cpp_initializer_lists} & \tcode{200806L} \\ \rowsep
1491+
\defnxname{cpp_inline_variables} & \tcode{201606L} \\ \rowsep
1492+
\defnxname{cpp_lambdas} & \tcode{200907L} \\ \rowsep
1493+
\defnxname{cpp_namespace_attributes} & \tcode{201411L} \\ \rowsep
1494+
\defnxname{cpp_noexcept_function_type} & \tcode{201510L} \\ \rowsep
1495+
\defnxname{cpp_nontype_template_args} & \tcode{201411L} \\ \rowsep
1496+
\defnxname{cpp_nontype_template_parameter_auto} & \tcode{201606L} \\ \rowsep
1497+
\defnxname{cpp_nsdmi} & \tcode{200809L} \\ \rowsep
1498+
\defnxname{cpp_range_based_for} & \tcode{201603L} \\ \rowsep
1499+
\defnxname{cpp_raw_strings} & \tcode{200710L} \\ \rowsep
1500+
\defnxname{cpp_ref_qualifiers} & \tcode{200710L} \\ \rowsep
1501+
\defnxname{cpp_return_type_deduction} & \tcode{201304L} \\ \rowsep
1502+
\defnxname{cpp_rvalue_references} & \tcode{200610L} \\ \rowsep
1503+
\defnxname{cpp_sized_deallocation} & \tcode{201309L} \\ \rowsep
1504+
\defnxname{cpp_static_assert} & \tcode{201411L} \\ \rowsep
1505+
\defnxname{cpp_structured_bindings} & \tcode{201606L} \\ \rowsep
1506+
\defnxname{cpp_template_template_args} & \tcode{201611L} \\ \rowsep
1507+
\defnxname{cpp_threadsafe_static_init} & \tcode{200806L} \\ \rowsep
1508+
\defnxname{cpp_unicode_characters} & \tcode{200704L} \\ \rowsep
1509+
\defnxname{cpp_unicode_literals} & \tcode{200710L} \\ \rowsep
1510+
\defnxname{cpp_user_defined_literals} & \tcode{200809L} \\ \rowsep
1511+
\defnxname{cpp_variable_templates} & \tcode{201304L} \\ \rowsep
1512+
\defnxname{cpp_variadic_templates} & \tcode{200704L} \\ \rowsep
1513+
\defnxname{cpp_variadic_using} & \tcode{201611L} \\ \rowsep
1514+
\end{LongTable}
1515+
13861516
\pnum
13871517
The following macro names are conditionally defined by the implementation:
13881518

source/support.tex

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,166 @@
516516
about the C++ standard library
517517
(e.g., version number and release date).
518518

519+
\pnum
520+
The macros in \tref{support.ft} are defined
521+
after inclusion of the header \tcode{<version>} or
522+
one of the corresponding headers specified in the table.
523+
\begin{note}
524+
Future versions of this International Standard might replace
525+
the values of these macros with greater values.
526+
\end{note}
527+
528+
\begin{LongTable}{Standard library feature-test macros}
529+
{tab:support.ft}{llx{.3\hsize}}
530+
\\ \topline
531+
\lhdr{Macro name} & \chdr{Value} & \rhdr{Header(s)} \\ \capsep
532+
\endfirsthead
533+
\continuedcaption \\
534+
\hline
535+
\lhdr{Macro name} & \chdr{Value} & \rhdr{Header(s)} \\ \capsep
536+
\endhead
537+
\defnlibxname{cpp_lib_addressof_constexpr} & \tcode{201603L} &
538+
\tcode{<memory>} \\ \rowsep
539+
\defnlibxname{cpp_lib_allocator_traits_is_always_equal} & \tcode{201411L} &
540+
\tcode{<memory>} \tcode{<scoped_allocator>} \tcode{<string>}
541+
\tcode{<deque>} \tcode{<forward_list>} \tcode{<list>} \tcode{<vector>}
542+
\tcode{<map>} \tcode{<set>} \tcode{<unordered_map>}
543+
\tcode{<unordered_set>} \\ \rowsep
544+
\defnlibxname{cpp_lib_any} & \tcode{201606L} &
545+
\tcode{<any>} \\ \rowsep
546+
\defnlibxname{cpp_lib_apply} & \tcode{201603L} &
547+
\tcode{<tuple>} \\ \rowsep
548+
\defnlibxname{cpp_lib_array_constexpr} & \tcode{201603L} &
549+
\tcode{<iterator>} \tcode{<array>} \\ \rowsep
550+
\defnlibxname{cpp_lib_as_const} & \tcode{201510L} &
551+
\tcode{<utility>} \\ \rowsep
552+
\defnlibxname{cpp_lib_atomic_is_always_lock_free} & \tcode{201603L} &
553+
\tcode{<atomic>} \\ \rowsep
554+
\defnlibxname{cpp_lib_bool_constant} & \tcode{201505L} &
555+
\tcode{<type_traits>} \\ \rowsep
556+
\defnlibxname{cpp_lib_boyer_moore_searcher} & \tcode{201603L} &
557+
\tcode{<functional>} \\ \rowsep
558+
\defnlibxname{cpp_lib_byte} & \tcode{201603L} &
559+
\tcode{<cstddef>} \\ \rowsep
560+
\defnlibxname{cpp_lib_chrono} & \tcode{201611L} &
561+
\tcode{<chrono>} \\ \rowsep
562+
\defnlibxname{cpp_lib_clamp} & \tcode{201603L} &
563+
\tcode{<algorithm>} \\ \rowsep
564+
\defnlibxname{cpp_lib_complex_udls} & \tcode{201309L} &
565+
\tcode{<complex>} \\ \rowsep
566+
\defnlibxname{cpp_lib_enable_shared_from_this} & \tcode{201603L} &
567+
\tcode{<memory>} \\ \rowsep
568+
\defnlibxname{cpp_lib_exchange_function} & \tcode{201304L} &
569+
\tcode{<utility>} \\ \rowsep
570+
\defnlibxname{cpp_lib_execution} & \tcode{201603L} &
571+
\tcode{<execution>} \\ \rowsep
572+
\defnlibxname{cpp_lib_filesystem} & \tcode{201703L} &
573+
\tcode{<filesystem>} \\ \rowsep
574+
\defnlibxname{cpp_lib_gcd_lcm} & \tcode{201606L} &
575+
\tcode{<numeric>} \\ \rowsep
576+
\defnlibxname{cpp_lib_generic_associative_lookup} & \tcode{201304L} &
577+
\tcode{<map>} \tcode{<set>} \\ \rowsep
578+
\defnlibxname{cpp_lib_hardware_interference_size} & \tcode{201703L} &
579+
\tcode{<new>} \\ \rowsep
580+
\defnlibxname{cpp_lib_has_unique_object_representations} & \tcode{201606L} &
581+
\tcode{<type_traits>} \\ \rowsep
582+
\defnlibxname{cpp_lib_hypot} & \tcode{201603L} &
583+
\tcode{<cmath>} \\ \rowsep
584+
\defnlibxname{cpp_lib_incomplete_container_elements} & \tcode{201505L} &
585+
\tcode{<forwardlist>} \tcode{<list>} \tcode{<vector>} \\ \rowsep
586+
\defnlibxname{cpp_lib_integer_sequence} & \tcode{201304L} &
587+
\tcode{<utility>} \\ \rowsep
588+
\defnlibxname{cpp_lib_integral_constant_callable} & \tcode{201304L} &
589+
\tcode{<type_traits>} \\ \rowsep
590+
\defnlibxname{cpp_lib_invoke} & \tcode{201411L} &
591+
\tcode{<functional>} \\ \rowsep
592+
\defnlibxname{cpp_lib_is_aggregate} & \tcode{201703L} &
593+
\tcode{<type_traits>} \\ \rowsep
594+
\defnlibxname{cpp_lib_is_final} & \tcode{201402L} &
595+
\tcode{<type_traits>} \\ \rowsep
596+
\defnlibxname{cpp_lib_is_invocable} & \tcode{201703L} &
597+
\tcode{<type_traits>} \\ \rowsep
598+
\defnlibxname{cpp_lib_is_null_pointer} & \tcode{201309L} &
599+
\tcode{<type_traits>} \\ \rowsep
600+
\defnlibxname{cpp_lib_is_swappable} & \tcode{201603L} &
601+
\tcode{<type_traits>} \\ \rowsep
602+
\defnlibxname{cpp_lib_launder} & \tcode{201606L} &
603+
\tcode{<new>} \\ \rowsep
604+
\defnlibxname{cpp_lib_logical_traits} & \tcode{201510L} &
605+
\tcode{<type_traits>} \\ \rowsep
606+
\defnlibxname{cpp_lib_make_from_tuple} & \tcode{201606L} &
607+
\tcode{<tuple>} \\ \rowsep
608+
\defnlibxname{cpp_lib_make_reverse_iterator} & \tcode{201402L} &
609+
\tcode{<iterator>} \\ \rowsep
610+
\defnlibxname{cpp_lib_make_unique} & \tcode{201304L} &
611+
\tcode{<memory>} \\ \rowsep
612+
\defnlibxname{cpp_lib_map_try_emplace} & \tcode{201411L} &
613+
\tcode{<map>} \\ \rowsep
614+
\defnlibxname{cpp_lib_math_special_functions} & \tcode{201603L} &
615+
\tcode{<cmath>} \\ \rowsep
616+
\defnlibxname{cpp_lib_memory_resource} & \tcode{201603L} &
617+
\tcode{<memory_resource>} \\ \rowsep
618+
\defnlibxname{cpp_lib_node_extract} & \tcode{201606L} &
619+
\tcode{<map>} \tcode{<set>} \tcode{<unordered_map>}
620+
\tcode{<unordered_set>} \\ \rowsep
621+
\defnlibxname{cpp_lib_nonmember_container_access} & \tcode{201411L} &
622+
\tcode{<iterator>} \tcode{<array>} \tcode{<deque>} \tcode{<forward_list>}
623+
\tcode{<list>} \tcode{<map>} \tcode{<regex>} \tcode{<set>} \tcode{<string>}
624+
\tcode{<unordered_map>} \tcode{<unordered_set>} \tcode{<vector>} \\ \rowsep
625+
\defnlibxname{cpp_lib_not_fn} & \tcode{201603L} &
626+
\tcode{<functional>} \\ \rowsep
627+
\defnlibxname{cpp_lib_null_iterators} & \tcode{201304L} &
628+
\tcode{<iterator>} \\ \rowsep
629+
\defnlibxname{cpp_lib_optional} & \tcode{201606L} &
630+
\tcode{<optional>} \\ \rowsep
631+
\defnlibxname{cpp_lib_parallel_algorithm} & \tcode{201603L} &
632+
\tcode{<algorithm>} \tcode{<numeric>} \\ \rowsep
633+
\defnlibxname{cpp_lib_quoted_string_io} & \tcode{201304L} &
634+
\tcode{<iomanip>} \\ \rowsep
635+
\defnlibxname{cpp_lib_raw_memory_algorithms} & \tcode{201606L} &
636+
\tcode{<memory>} \\ \rowsep
637+
\defnlibxname{cpp_lib_result_of_sfinae} & \tcode{201210L} &
638+
\tcode{<functional>} \tcode{<type_traits>} \\ \rowsep
639+
\defnlibxname{cpp_lib_robust_nonmodifying_seq_ops} & \tcode{201304L} &
640+
\tcode{<algorithm>} \\ \rowsep
641+
\defnlibxname{cpp_lib_sample} & \tcode{201603L} &
642+
\tcode{<algorithm>} \\ \rowsep
643+
\defnlibxname{cpp_lib_scoped_lock} & \tcode{201703L} &
644+
\tcode{<mutex>} \\ \rowsep
645+
\defnlibxname{cpp_lib_shared_mutex} & \tcode{201505L} &
646+
\tcode{<shared_mutex>} \\ \rowsep
647+
\defnlibxname{cpp_lib_shared_ptr_arrays} & \tcode{201611L} &
648+
\tcode{<memory>} \\ \rowsep
649+
\defnlibxname{cpp_lib_shared_ptr_weak_type} & \tcode{201606L} &
650+
\tcode{<memory>} \\ \rowsep
651+
\defnlibxname{cpp_lib_shared_timed_mutex} & \tcode{201402L} &
652+
\tcode{<shared_mutex>} \\ \rowsep
653+
\defnlibxname{cpp_lib_string_udls} & \tcode{201304L} &
654+
\tcode{<string>} \\ \rowsep
655+
\defnlibxname{cpp_lib_string_view} & \tcode{201606L} &
656+
\tcode{<string>} \tcode{<string_view>} \\ \rowsep
657+
\defnlibxname{cpp_lib_to_chars} & \tcode{201611L} &
658+
\tcode{<utility>} \\ \rowsep
659+
\defnlibxname{cpp_lib_transformation_trait_aliases} & \tcode{201304L} &
660+
\tcode{<type_traits>} \\ \rowsep
661+
\defnlibxname{cpp_lib_transparent_operators} & \tcode{201510L} &
662+
\tcode{<memory>} \tcode{<functional>} \\ \rowsep
663+
\defnlibxname{cpp_lib_tuple_element_t} & \tcode{201402L} &
664+
\tcode{<tuple>} \\ \rowsep
665+
\defnlibxname{cpp_lib_tuples_by_type} & \tcode{201304L} &
666+
\tcode{<utility>} \tcode{<tuple>} \\ \rowsep
667+
\defnlibxname{cpp_lib_type_trait_variable_templates} & \tcode{201510L} &
668+
\tcode{<type_traits>} \\ \rowsep
669+
\defnlibxname{cpp_lib_uncaught_exceptions} & \tcode{201411L} &
670+
\tcode{<exception>} \\ \rowsep
671+
\defnlibxname{cpp_lib_unordered_map_try_emplace} & \tcode{201411L} &
672+
\tcode{<unordered_map>} \\ \rowsep
673+
\defnlibxname{cpp_lib_variant} & \tcode{201606L} &
674+
\tcode{<variant>} \\ \rowsep
675+
\defnlibxname{cpp_lib_void_t} & \tcode{201411L} &
676+
\tcode{<type_traits>} \\ \rowsep
677+
\end{LongTable}
678+
519679
\rSec2[limits.syn]{Header \tcode{<limits>} synopsis}
520680
\indexhdr{limits}%
521681
\indextext{\idxcode{numeric_limits}}%

0 commit comments

Comments
 (0)