Skip to content

Specification Style Guidelines

sdutoit edited this page May 23, 2012 · 106 revisions

Standards Wording Idioms

This is a list of some common idioms in the standard that should be used to specify certain cases, and corresponding anti-idioms that should not be used.

When you are writing proposals for changes to the C++ standard, please try to follow these idioms. If you notice an anti-idiom in the current C++ standards draft, please [submit an editorial issue](How to submit an editorial issue).

Case Idiom(s) Anti-idiom(s) Example
Normative requirement
Use this idiom when specifying something we require a conforming implementation to do.
  • Implementations shall […]
  • <language feature X> shall […]
  • […] must […]

"Unless it is a bit-field, a most derived object shall have a non-zero size"
Normative encouragement
Use this idiom when specifying something we would prefer, but do not require, implementations to do.
  • Implementations should […]
  • Implementations are encouraged, but not required, to […]
"Implementations should ensure that all unblocked threads eventually make progress"
Complicated conditional cases
Use this idiom when you are enumerating a set of possibilities, and stating requirements under those possibilities.
  • If […], then […].
    If […], then […].

    Otherwise […]
  • […], except when […], then […], or when […], then […]
"If E1 is an lvalue, then E1.E2 is an lvalue; if E1 is an xvalue, then E1.E2 is an xvalue; otherwise, it is a prvalue."

Missing idioms

  • Variations on "ill-formed"

Library conventions

Specifying implicitly generated special member functions

When you are specifying a class containing implicitly generated member functions, do not provide a detailed specification of these, as their behavior is implied by the language rules. Instead, list the member functions using the = default mechanism in the class synopsis only. For example:

class my_class {
  // ...
public:
  my_class() noexcept = default;
  my_class(const my_class&) = default;
  my_class& operator=(const my_class&) = default;
  my_class(my_class&&) noexcept = default;
  my_class& operator=(my_class&&) noexcept = default;
  ~my_class() noexcept = default;
  // ...
};

ISO Directives

Rules for the overall structure and form of ISO standards is provided by the ISO Directives, Part 2. This covers rules common to all ISO documents, such as the meaning of should and shall) above, and the referencing of other standards documents.

Clone this wiki locally