Skip to content

Latest commit

 

History

History
343 lines (263 loc) · 8.19 KB

TEST.md

File metadata and controls

343 lines (263 loc) · 8.19 KB
title subtitle document date audience author toc toc-depth
Test document for mpark/wg21
Visual inspection of various features of the framework
D0000R0
today
Library Evolution
Library
name email
Michael Park
true
2

Introduction

This framework provides support for various common elements for C++ papers. This document is intended to test various features implemented in mpark/wg21.

Title

The title is specified by YAML metadata block.

---
title: Example Title
subtitle: Example Subtitle
document: DxxxxRn
date: 2019-06-13
audience:
  - Library Evolution
  - Library
author:
  - name: Author One
    email: <[email protected]>
  - name: Author Two
    email: <[email protected]>
toc: false    # default: `true`
toc-depth: 4  # default: `3`
---

date: today will generate today's date in YYYY-MM-DD (ISO 8601) format.

Markdown

Pandoc Markdown is the Markdown flavor used for this framework.

Inline Formatting

Inline formatting such as bold, italics, and verbatim work as you would expect. There are also useful extensions such as strikeout, subscript, su^per^script, and highlighted code: constexpr{.cpp}.

Various compositions in compact list:

  • A<B<T>>{.cpp}
  • compare_3way{.cpp}
  • 3WAY{.default}<R>{.cpp}
  • operator@{.cpp}
  • operator+{.cpp}
  • x @ y{.cpp}
  • x & y{.cpp}
  • foo constexpr{.cpp} bar
  • foo constexpr{.cpp} bar
  • foo constexpr{.cpp} bar
  • [hello world]{.add}
  • hello world
  • hello world
  • namespace @_unspecified_@ { struct sender_base {}; }
  • namespace @_unspecified_@ { struct sender_base {}; }{.cpp}

Loose list:

  • x@~_i_~@ <=> y@~_i_~@{.cpp}

  • [foo hello world bar]{.rm}

Inline Code in Headers: int{.cpp}, x & y{.cpp}

Code Block

No Syntax Highlighting

#include <iostream>
#include "foo.h"

__FILE__;

int x = 42'234'234;
const int x = 42ul;
const int x = 0B01011;

bool b = true;

struct process {
  hello @[constexpr]{.rm}@ detail::foo::template @_foo_@;

  [[using CC: opt(1), debug]] x;

  template <typename I>
  [[nodiscard]] auto operator()(I i) -> O<I> { /* ... */ };
};

@@[`namespace @_unspecified_@ { struct sender_base {}; }`]{.add}@@
@@[`using @_unspecified_@::sender_base;`]{.add}@@

@@[`template<class, class> struct @_as-receiver_@; @_// exposition only_@`]{.add}@@
@@[`template<class, class> struct @_as-invocable_@; @_// exposition only_@`]{.add}@@

C++ Syntax Highlighting

#include <iostream>
#include "foo.h"

__FILE__;

int x = 42'234'234;
const int x = 42ul;
const int x = 0B01011;

bool b = true;

struct process {
  hello @[`constexpr`]{.add}@ detail::foo::template foo;

  [[using CC: opt(1), debug]] x;

  template <typename I>
  [[nodiscard]] auto operator()(I i) -> O<I> { /* ... */ };

  x@~_i_~@ <=> y@~_i_~@;
};

if (x) {
  return ""sv;
  return 5ms;
}

std::printf("%d", x);

std::variant<I1, I2> input = 'h';
std::variant<I1, I2> input = "h";
std::variant<I1, I2> input = "hello";

// mapping from a `variant` of inputs to a `variant` of results:
auto output = std::visit<std::variant<O<I1>, O<I2>>>(process{}, input);

// coercing different results to a common type:
auto result = std::visit<std::common_type_t<O<I1>, O<I2>>>(process{}, input);

// visiting a `variant` for the side-effects, discarding results:
std::visit<void>(process{}, input);

@@[`namespace @_unspecified_@ { struct sender_base {}; }`]{.add}@@
@@[`using @_unspecified_@::sender_base;`]{.add}@@

diff Syntax Highlighting

some things just don't change.

// 20.3.4 tuple-like access to pair:
- constexpr typename tuple_element<I, std::pair<T1, T2> >::type&
+ constexpr tuple_element_t<I, pair<T1, T2> >&
-   get(std::pair<T1, T2>&) noexcept;
+   get(pair<T1, T2>&) noexcept;

@_unspecified_@ detail::foo::template foo;
+ @_unspecified_@ detail::foo::template foo;
- @_unspecified_@ detail::foo::template foo;

Comparison Tables

::: cmptable

Put your caption here

Before

switch (x) {
  case 0: std::cout << "got zero"; break;
  case 1: std::cout << "got one"; break;
  default: std::cout << "don't care";
}

After

inspect (x) {
  0: std::cout << "got zero";
  1: std::cout << "got one";
  _: std::cout << "don't care";
}

:::

::: cmptable

Before

switch (x) {
  case 0: std::cout << "got zero"; break;
  case 1: std::cout << "got one"; break;
  default: std::cout << "don't care";
}

After

inspect (x) {
  0: std::cout << "got zero";
  1: std::cout << "got one";
  _: std::cout << "don't care";
}

if (s == "foo") {
  std::cout << "got foo";
} else if (s == "bar") {
  std::cout << "got bar";
} else {
  std::cout << "don't care";
}
inspect (s) {
  "foo": std::cout << "got foo";
  "bar": std::cout << "got bar";
  _: std::cout << "don't care";
}

:::

Proposed Wording

Paragraph Numbers

[2]{.pnum} An expression is potentially evaluated unless it is an unevaluated operand (7.2) or a subexpression thereof. The set of potential results of an expression e is defined as follows:

  • [2.1]{.pnum} If e is an id-expression (7.5.4), the set contains only e.

  • [2.2]{.pnum} If e is a subscripting operation (7.6.1.1) with an array operand, the set contains the potential results of that operand.

Wording Changes

Large changes are ::: add for additions, ::: rm for removals.

Modify section [format.functions]{.sref}:

::: add

template<class... Args>
  string format(const locale& loc, string_view fmt, const Args&... args);

Returns: vformat(loc, fmt, make_format_args(args...)).

:::

Small, inline changes are done with [new text]{.add} or [old text]{.rm}.

+-----------+--------------------------------------------------------------------+ | Specifier | Replacement | +===========+====================================================================+ | %a | The locale’s abbreviated weekday name. If the value does not | | | contain a valid weekday, [setstate(ios::failbit) is called]{.rm} | | | [format_error is thrown]{.add}. | +-----------+--------------------------------------------------------------------+ | %A | The locale’s full weekday name. If the value does not contain | | | a valid weekday, [setstate(ios::failbit) is called]{.rm} | | | [format_error is thrown]{.add}. | +-----------+--------------------------------------------------------------------+

Grammar Changes

| selection-statement: | if constexpropt ( init-statementopt condition ) statement | if constexpropt ( init-statementopt condition ) statement else statement | switch ( init-statementopt condition ) statement | [inspect constexpropt ( init-statementopt condition ) { inspect-case-seq }]{.add}

::: add | inspect-case-seq: | inspect-case | inspect-case-seq inspect-case

| inspect-case: | attribute-specifier-seqopt inspect-pattern inspect-guardopt : statement

| inspect-pattern: | wildcard-pattern | identifier-pattern | constant-pattern | structured-binding-pattern | alternative-pattern | binding-pattern | extractor-pattern

| inspect-guard: | if ( expression ) :::

Stable Names

Stable names are written as [basic.life]{.sref}, and renders as [basic.life]{.sref}. It uses https://timsong-cpp.github.io/cppwp/annex-f.

Citation

Automatic references are written as [@N4762] and renders as [@N4762]. Anything in https://wg21.link/index.yaml are linked automatically.

  • N Papers (e.g., [@N3887] [@N3887])
  • P Papers (e.g., [@P1371R1] [@P1371R1])
  • CWG Issues (e.g., [@CWG1234] [@CWG1234])
  • LWG Issues (e.g., [@LWG1234] [@LWG1234])
  • Github Edits (e.g, [@EDIT1234] [@EDIT1234])
  • Standing Documents (e.g., [@SD6] [@SD6])