LoginSignup
0
0

More than 1 year has passed since last update.

27.10 Generalized numeric operations [numeric.ops] C++N4910:2022 (664) p1252.cpp

Last updated at Posted at 2022-08-16

はじめに(Introduction)

N4910 Working Draft, Standard for Programming Language C++

n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 WG21では、可能な限り作業文書を公開し、幅広い意見を求めています。
一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, TOPPERSカーネル、g++(GCC), clang++(LLVM)との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。

<この項は書きかけです。順次追記します。>

背景(back ground)

C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに1回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。

この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を10種類以上、最近になって解決できたことがあります。それは、主に次の3つの情報に基づいています。

cpprefjp - C++日本語リファレンス

コンパイラの実装状況

また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。

作業方針(sequence)

Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの2種類
でコンパイルし、

1)コンパイルエラーを収集する。
2)コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
3)リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
4)意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。

1)だけのものから4)まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。

C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list

C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list

C++N4606, 2016符号断片編纂一覧(example code compile list)

C++N4606, 2016 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

C++N3242, 2011 sample code compile list on clang++ and g++

編纂器(Compiler)

clang++ --version

Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
Target: x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin

g++- --version

g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

27.10 Generalized numeric operations [numeric.ops] C++N4910:2022 (664) p1252.cpp

算譜(source code)

p1252.cpp// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "27.10 Generalized numeric operations [numeric.ops] C++N4910:2022 (664) p1252.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. OGAWA Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

#include "N4910.h"

using namespace std;

// 27.10.1 General [numeric.ops.general]
// [Note 1: The use of closed ranges as well as semi-open ranges to specify requirements throughout 27.10 is intentional.
// 27.10.2 Definitions [numerics.defns]
// Define GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN) as follows:
// — a1 when N is 1, otherwise
// — op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) for any K where 1 < K + 1 = M ≤ N. Define GENERALIZED_SUM(op, a1, ..., aN) as GENERALIZED_NONCOMMUTATIVE_SUM(op, b1, ..., bN), where b1, ..., bN may be any permutation of a1, ..., aN.
// 27.10.3 Accumulate [accumulate]
template<class InputIterator, class T>
constexpr T accumulate(InputIterator first, InputIterator last, T init);
template<class InputIterator, class T, class BinaryOperation>
constexpr T accumulate(InputIterator first, InputIterator last, T init,
                       BinaryOperation binary_op);
// Preconditions: T meets the Cpp17CopyConstructible (Table 31) and Cpp17CopyAssignable (Table 33) requirements. In the range [first, last], binary_op neither modifies elements nor invalidates iterators or subranges.225
// Effects: Computes its result by initializing the accumulator acc with the initial value init and then modifies it with acc = std::move(acc) + *i or acc = binary_op(std::move(acc), *i) for every iterator i in the range [first, last) in order.226
template<class ExecutionPolicy, class ForwardIterator>
typename iterator_traits<ForwardIterator>::value_type
// 27.10.4 Reduce [reduce]
template<class InputIterator>
constexpr typename iterator_traits<InputIterator>::value_type
reduce(InputIterator first, InputIterator last);
// Effects: Equivalent to:
return reduce(first, last,
              typename iterator_traits<InputIterator>::value_type{});
reduce(ExecutionPolicy&& exec,
       ForwardIterator first, ForwardIterator last);
// Effects: Equivalent to:
return reduce(std::forward<ExecutionPolicy>(exec), first, last,
              typename iterator_traits<ForwardIterator>::value_type{});
template<class InputIterator, class T>
constexpr T reduce(InputIterator first, InputIterator last, T init);
// Effects: Equivalent to:
return reduce(first, last, init, plus<>());
template<class ExecutionPolicy, class ForwardIterator, class T>
T reduce(ExecutionPolicy&& exec,
         ForwardIterator first, ForwardIterator last, T init);
// Effects: Equivalent to:
return reduce(std::forward<ExecutionPolicy>(exec), first, last, init, plus<>());
template<class InputIterator, class T, class BinaryOperation>
constexpr T reduce(InputIterator first, InputIterator last, T init,
                   BinaryOperation binary_op);
template<class ExecutionPolicy, class ForwardIterator, class T, class BinaryOperation>
T reduce(ExecutionPolicy&& exec,
         ForwardIterator first, ForwardIterator last, T init,
         BinaryOperation binary_op);
// Mandates: All of
// — binary_op(init, *first), — binary_op(*first, init), — binary_op(init, init), and — binary_op(*first, *first) are convertible to T.
// Preconditions: -  T meets the Cpp17MoveConstructible (Table 30) requirements.
// — binary_op neither invalidates iterators or subranges, nor modifies elements in the range [first, last].
// Returns: GENERALIZED_SUM(binary_op, init, *i, ...) for every i in [first, last). Complexity: O(last - first) applications of binary_op.
// [Note 1: The difference between reduce and accumulate is that reduce applies binary_op in an unspecified order, which yields a nondeterministic result for non-associative or non-commutative binary_op such as floating-point addition. —end note]
// 27.10.5 Inner product [inner.product]
template<class InputIterator1, class InputIterator2, class T>
constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
                          InputIterator2 first2, T init);
T transform_reduce(ExecutionPolicy&& exec,
                   ForwardIterator1 first1, ForwardIterator1 last1,
                   ForwardIterator2 first2,
                   T init,
                   BinaryOperation1 binary_op1,
                   BinaryOperation2 binary_op2);
// Mandates: All of
// — binary_op1(init, init),
// — binary_op1(init, binary_op2(*first1, *first2)),
// — binary_op1(binary_op2(*first1, *first2), init), and
// — binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))
template<class InputIterator1, class InputIterator2, class T,
         class BinaryOperation1, class BinaryOperation2>
constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
                          InputIterator2 first2, T init,
                          BinaryOperation1 binary_op1,
                          BinaryOperation2 binary_op2);
// Preconditions: T meets the Cpp17CopyConstructible (Table 31) and Cpp17CopyAssignable (Table 33) requirements. In the ranges [first1, last1] and [first2, first2 + (last1 - first1)] binary_op1 and binary_op2 neither modifies elements nor invalidates iterators or subranges.227
// Effects: Computes its result by initializing the accumulator acc with the initial value init and then modifying it with acc = std::move(acc) + (*i1) * (*i2) or acc = binary_op1(std::move(acc), binary_op2(*i1, *i2)) for every iterator i1 in the range [first1, last1) and iterator //  in the range [first2, first2 + (last1 - first1)) in order.
// 27.10.6 Transform reduce [transform.reduce]
template<class InputIterator1, class InputIterator2, class T>
constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
                             InputIterator2 first2, T init);
// Effects: Equivalent to:
return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
template<class ExecutionPolicy,
         class ForwardIterator1, class ForwardIterator2, class T>
T transform_reduce(ExecutionPolicy&& exec,
                   ForwardIterator1 first1, ForwardIterator1 last1,
                   ForwardIterator2 first2,
                   T init);
// Effects: Equivalent to:
return transform_reduce(std::forward<ExecutionPolicy>(exec),
                        first1, last1, first2, init, plus<>(), multiplies<>());
template<class InputIterator1, class InputIterator2, class T,
         class BinaryOperation1, class BinaryOperation2>
constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
                             InputIterator2 first2,
                             T init,
                             BinaryOperation1 binary_op1,
                             BinaryOperation2 binary_op2);
template<class ExecutionPolicy,
         class ForwardIterator1, class ForwardIterator2, class T,
         class BinaryOperation1, class BinaryOperation2>
// are convertible to T. Preconditions:
// — T meets the Cpp17MoveConstructible (Table 30) requirements.
// — Neither binary_op1 nor binary_op2 invalidates subranges, nor modifies elements in the ranges
// [first1, last1] and [first2, first2 + (last1 - first1)].
// Returns:
GENERALIZED_SUM(binary_op1, init, binary_op2(*i, *(first2 + (i - first1))), ...) for every iterator i in [first1, last1).
// Complexity: O(last1 - first1) applications each of binary_op1 and binary_op2.
            class BinaryOperation, class UnaryOperation>
                    T transform_reduce(ExecutionPolicy&& exec,
                                       ForwardIterator first, ForwardIterator last,
                                       T init, BinaryOperation binary_op, UnaryOperation unary_op);
// Mandates: All of
// — binary_op(init, init),
// — binary_op(init, unary_op(*first)),
// — binary_op(unary_op(*first), init), and
// — binary_op(unary_op(*first), unary_op(*first)) are convertible to T. Preconditions:
// — T meets the Cpp17MoveConstructible (Table 30) requirements.
// — Neither unary_op nor binary_op invalidates subranges, nor modifies elements in the range
// Mandates: InputIterator’s value type is constructible from *first. The result of the expression std::move(acc) + *i or binary_op(std::move(acc), *i) is implicitly convertible to InputItera- tor’s value type. acc is writable (25.3.1) to result.
// Preconditions: In the ranges [first, last] and [result, result + (last // - first)] binary_op neither modifies elements nor invalidates iterators or subranges.228
        template<class InputIterator, class T,
                 class BinaryOperation, class UnaryOperation>
        constexpr T transform_reduce(InputIterator first, InputIterator last, T init,
                                     BinaryOperation binary_op, UnaryOperation unary_op);
template<class ExecutionPolicy,
         class ForwardIterator, class T, [first, last].
// Returns:
         GENERALIZED_SUM(binary_op, init, unary_op(*i), ...)
// for every iterator i in [first, last).
// Complexity: O(last - first) applications each of unary_op and binary_op.
//  [Note 1: transform_reduce does not apply unary_op to init.
// 27.10.7 Partial sum [partial.sum]
         template<class InputIterator, class OutputIterator>
         constexpr OutputIterator
         partial_sum(InputIterator first, InputIterator last,
                     OutputIterator result);
template<class InputIterator, class OutputIterator, class BinaryOperation>
constexpr OutputIterator
partial_sum(InputIterator first, InputIterator last,
            OutputIterator result, BinaryOperation binary_op);
ForwardIterator2
exclusive_scan(ExecutionPolicy&& exec,
               ForwardIterator1 first, ForwardIterator1 last,
               ForwardIterator2 result, T init, BinaryOperation binary_op);
// Mandates: All of
// — binary_op(init, init),
// — binary_op(init, *first), and — binary_op(*first, *first) are convertible to T. Preconditions:
// — T meets the Cpp17MoveConstructible (Table 30) requirements.
// — binary_op neither invalidates iterators or subranges, nor modifies elements in the ranges [first, last] or [result, result + (last - first)].
// Effects: For each integer K in [0, last - first) assigns through result + K the value of:
GENERALIZED_NONCOMMUTATIVE_SUM( binary_op, init, *(first + 0), *(first + 1), ..., *(first + K - 1))
// Returns: The end of the resulting range beginning at result.
// Complexity: O(last - first) applications of binary_op. Remarks: result may be equal to first.
// [Note 1: The difference between exclusive_scan and inclusive_scan is that exclusive_scan excludes the ith input element from the ith sum. If binary_op is not mathematically associative, the behavior of exclusive_scan can be nondeterministic.
// Effects: For a non-empty range, the function creates an accumulator acc whose type is InputIterator’s value type, initializes it with *first, and assigns the result to *result. For every iterator i in [first + 1, last) in order, acc is then modified by acc = std::move(acc) + *i or acc = binary_- op(std::move(acc), *i) and the result is assigned to *(result + (i - first)).
// Returns: result + (last - first).
// Complexity: Exactly (last - first) - 1 applications of the binary operation. Remarks: result may be equal to first.
// 27.10.8 Exclusive scan [exclusive.scan]
template<class InputIterator, class OutputIterator, class T>
constexpr OutputIterator
exclusive_scan(InputIterator first, InputIterator last,
               OutputIterator result, T init);
// Effects: Equivalent to:
return exclusive_scan(first, last, result, init, plus<>());
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T>
ForwardIterator2
exclusive_scan(ExecutionPolicy&& exec,
               ForwardIterator1 first, ForwardIterator1 last,
               ForwardIterator2 result, T init);
// Effects: Equivalent to:
return exclusive_scan(std::forward<ExecutionPolicy>(exec),
                      first, last, result, init, plus<>());
template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
constexpr OutputIterator
exclusive_scan(InputIterator first, InputIterator last,
               OutputIterator result, T init, BinaryOperation binary_op);
template<class ExecutionPolicy,
         class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation>
ForwardIterator2
inclusive_scan(ExecutionPolicy&& exec,
               ForwardIterator1 first, ForwardIterator1 last,
               ForwardIterator2 result, BinaryOperation binary_op, T init);
// Let U be the value type of decltype(first). Mandates: If init is provided, all of
// — binary_op(init, init),
// — binary_op(init, *first), and — binary_op(*first, *first) are convertible to T; otherwise, binary_op(*first, *first) is convertible to U. Preconditions:
// — If init is provided, T meets the Cpp17MoveConstructible (Table 30) requirements; otherwise, U meets the Cpp17MoveConstructible requirements.
// — binary_op neither invalidates iterators or subranges, nor modifies elements in the ranges [first, last] or [result, result + (last - first)].
// Effects: For each integer K in [0, last - first) assigns through result + K the value of
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator2
// 27.10.9 Inclusive scan [inclusive.scan]
template<class InputIterator, class OutputIterator>
constexpr OutputIterator
inclusive_scan(InputIterator first, InputIterator last,
               OutputIterator result);
// Effects: Equivalent to:
return inclusive_scan(first, last, result, plus<>());
inclusive_scan(ExecutionPolicy&& exec,
               ForwardIterator1 first, ForwardIterator1 last,
               ForwardIterator2 result);
// Effects: Equivalent to:
return inclusive_scan(std::forward<ExecutionPolicy>(exec), first, last, result, plus<>());
template<class InputIterator, class OutputIterator, class BinaryOperation>
constexpr OutputIterator
inclusive_scan(InputIterator first, InputIterator last,
               OutputIterator result, BinaryOperation binary_op);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
         class BinaryOperation>
ForwardIterator2
inclusive_scan(ExecutionPolicy&& exec,
               ForwardIterator1 first, ForwardIterator1 last,
               ForwardIterator2 result, BinaryOperation binary_op);
template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
constexpr OutputIterator
inclusive_scan(InputIterator first, InputIterator last,
               OutputIterator result, BinaryOperation binary_op, T init);
template<class ExecutionPolicy,
         class ForwardIterator1, class ForwardIterator2, class BinaryOperation, class T>
GENERALIZED_NONCOMMUTATIVE_SUM(
    binary_op, init, *(first + 0), *(first + 1), ..., *(first + K))
// if init is provided, or
GENERALIZED_NONCOMMUTATIVE_SUM(
    binary_op, *(first + 0), *(first + 1), ..., *(first + K))
otherwise.
class ForwardIterator1, class ForwardIterator2, class T,
class BinaryOperation, class UnaryOperation>
ForwardIterator2
transform_exclusive_scan(ExecutionPolicy&& exec,
                         ForwardIterator1 first, ForwardIterator1 last,
                         ForwardIterator2 result, T init,
                         BinaryOperation binary_op, UnaryOperation unary_op);
// Mandates: All of
// — binary_op(init, init),
// — binary_op(init, unary_op(*first)), and
// — binary_op(unary_op(*first), unary_op(*first)) are convertible to T. Preconditions:
// — T meets the Cpp17MoveConstructible (Table 30) requirements.
// — Neither unary_op nor binary_op invalidates iterators or subranges, nor modifies elements in the ranges [first, last] or [result, result + (last - first)].
// Effects: For each integer K in [0, last - first) assigns through result + K the value of: GENERALIZED_NONCOMMUTATIVE_SUM( binary_op, init, unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K - 1)))
// Returns: The end of the resulting range beginning at result.
// Complexity: O(last - first) applications each of unary_op and binary_op. Remarks: result may be equal to first.
// [Note 1: The difference between transform_exclusive_scan and transform_inclusive_scan is that trans- form_exclusive_scan excludes the ith input element from the ith sum. If binary_op is not mathematically associative, the behavior of transform_exclusive_scan can be nondeterministic. transform_exclusive_scan does not apply unary_op to init.
// Returns: The end of the resulting range beginning at result. // Complexity: O(last - first) applications of binary_op. Remarks: result may be equal to first.
// [Note 1: The difference between exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum. If binary_op is not mathematically associative, the behavior of inclusive_scan can be nondeterministic.
// 27.10.10 Transform exclusive scan [transform.exclusive.scan]
template<class InputIterator, class OutputIterator, class T,
         class BinaryOperation, class UnaryOperation>
constexpr OutputIterator
transform_exclusive_scan(InputIterator first, InputIterator last,
                         OutputIterator result, T init,
                         BinaryOperation binary_op, UnaryOperation unary_op);
template<class ExecutionPolicy,
// 27.10.11 Transform inclusive scan [transform.inclusive.scan]
         template<class InputIterator, class OutputIterator,
                  class BinaryOperation, class UnaryOperation>
         constexpr OutputIterator
         transform_inclusive_scan(InputIterator first, InputIterator last,
                                  OutputIterator result,
                                  BinaryOperation binary_op, UnaryOperation unary_op);
template<class ExecutionPolicy,
         class ForwardIterator1, class ForwardIterator2,
         class BinaryOperation, class UnaryOperation>
ForwardIterator2
transform_inclusive_scan(ExecutionPolicy&& exec,
                         ForwardIterator1 first, ForwardIterator1 last,
                         ForwardIterator2 result,
                         BinaryOperation binary_op, UnaryOperation unary_op);
template<class InputIterator, class OutputIterator,
         class BinaryOperation, class UnaryOperation, class T>
constexpr OutputIterator
transform_inclusive_scan(InputIterator first, InputIterator last,
                         OutputIterator result,
                         BinaryOperation binary_op, UnaryOperation unary_op,
                         T init);
template<class ExecutionPolicy,
         class ForwardIterator1, class ForwardIterator2,
         class BinaryOperation, class UnaryOperation, class T>
ForwardIterator2
transform_inclusive_scan(ExecutionPolicy&& exec,
                         ForwardIterator1 first, ForwardIterator1 last,
                         ForwardIterator2 result,
                         BinaryOperation binary_op, UnaryOperation unary_op,
                         T init);
// Let U be the value type of decltype(first). Mandates: If init is provided, all of
// — binary_op(init, init),
// — binary_op(init, unary_op(*first)), and
// — binary_op(unary_op(*first), unary_op(*first)) are convertible to T; otherwise, binary_op(unary_op(*first), unary_op(*first)) is convertible to U.
// Preconditions: — If init is provided, T meets the Cpp17MoveConstructible (Table 30) requirements; otherwise, U meets the Cpp17MoveConstructible requirements.
// — Neither unary_op nor binary_op invalidates iterators or subranges, nor modifies elements in the ranges [first, last] or [result, result + (last - first)].
// Effects: For each integer K in [0, last - first) assigns through result + K the value of
// — GENERALIZED_NONCOMMUTATIVE_SUM( binary_op, init, unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K))) if init is provided, or
// — GENERALIZED_NONCOMMUTATIVE_SUM( binary_op,
unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K)))
// otherwise.
// Returns: The end of the resulting range beginning at result.
// Complexity: O(last - first) applications each of unary_op and binary_op. Remarks: result may be equal to first.
// [Note 1: The difference between transform_exclusive_scan and transform_inclusive_scan is that trans- form_inclusive_scan includes the ith input element in the ith sum. If binary_op is not mathematically associative, the behavior of transform_inclusive_scan can be nondeterministic. transform_inclusive_scan does not apply unary_op to init.
// 27.10.12 Adjacent difference [adjacent.difference]
template<class InputIterator, class OutputIterator>
constexpr OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
                    OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
ForwardIterator2
adjacent_difference(ExecutionPolicy&& exec,
                    ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result);
template<class InputIterator, class OutputIterator, class BinaryOperation>
constexpr OutputIterator
adjacent_difference(InputIterator first, InputIterator last,
                    OutputIterator result, BinaryOperation binary_op);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
         class BinaryOperation>
ForwardIterator2
adjacent_difference(ExecutionPolicy&& exec,
                    ForwardIterator1 first, ForwardIterator1 last,
                    ForwardIterator2 result, BinaryOperation binary_op);
// Let T be the value type of decltype(first). For the overloads that do not take an argument binary_op, let binary_op be an lvalue that denotes an object of type minus<>.
// Mandates: — For the overloads with no ExecutionPolicy, T is constructible from *first. acc (defined below) is writable (25.3.1) to the result output iterator. The result of the expression binary_op(val, std::move(acc)) is writable to result.
//  — For the overloads with an ExecutionPolicy, the result of the expressions binary_op(*first, *first) and *first are writable to result.
// Preconditions: — For the overloads with no ExecutionPolicy, T meets the Cpp17MoveAssignable (Table 32) requirements.
// — For all overloads, in the ranges [first, last] and [result, result + (last - first)], binary_-op neither modifies elements nor invalidate iterators or subranges.
// Effects: For the overloads with no ExecutionPolicy and a non-empty range, the function creates an accumulator acc of type T, initializes it with *first, and assigns the result to *result. For every iterator i in [first + 1, last) in order, creates an object val whose type is T, initializes it with *i, computes binary_op(val, std::move(acc)), assigns the result to *(result + (i - first)), and move assigns from val to acc.
// For the overloads with an ExecutionPolicy and a non-empty range, performs *result = *first. Then, for every d in [1, last - first - 1], performs *(result + d) = binary_op(*(first + d), *(first + (d - 1))).
// Returns: result + (last - first).
// Complexity: Exactly (last - first) - 1 applications of the binary operation.
// Remarks: For the overloads with no ExecutionPolicy, result may be equal to first. For the overloads with an ExecutionPolicy, the ranges [first, last) and [result, result + (last - first)) shall not overlap.
//  [numeric.iota]
template<class ForwardIterator, class T>
constexpr void iota(ForwardIterator first, ForwardIterator last, T value);
// Mandates: T is convertible to ForwardIterator’s value type. The expression ++val, where val has type T, is well-formed.
// Effects: For each element referred to by the iterator i in the range [first, last), assigns *i = value and increments value as if by ++value.
// Complexity: Exactly last - first increments and assignments.
template<input_or_output_iterator O, sentinel_for<O> S, weakly_incrementable T>
requires indirectly_writable<O, const T&>
constexpr ranges::iota_result<O, T> ranges::iota(O first, S last, T value);
template<weakly_incrementable T, output_range<const T&> R>
constexpr ranges::iota_result<borrowed_iterator_t<R>, T> ranges::iota(R&& r, T value);
// Effects: Equivalent to:
while (first != last) {
*first = as_const(value);
    ++first;
    ++value;
}
return {std::move(first), std::move(value)};
// Mandates: M and N both are integer types other than cv bool.
// Preconditions: |m| and |n| are representable as a value of common_type_t<M, N>.
// [Note 1 : These requirements ensure, for example, that gcd(m, m) = |m| is representable as a value of type M.
// Returns: Zero when m and n are both zero. Otherwise, returns the greatest common divisor of |m| and |n|.
// 27.10.14 Greatest common divisor [numeric.ops.gcd]
template<class M, class N>
constexpr common_type_t<M, N> gcd(M m, N n);
// Throws: Nothing.
// 27.10.15 Least common multiple [numeric.ops.lcm]
template<class M, class N>
constexpr common_type_t<M, N> lcm(M m, N n);
// Mandates: M and N both are integer types other than cv bool.
// Preconditions: |m| and |n| are representable as a value of common_type_t<M, N>. The least common multiple of |m| and |n| is representable as a value of type common_type_t<M, N>.
// Returns: Zero when either m or n is zero. Otherwise, returns the least common multiple of |m| and |n|. Throws: Nothing.
// 27.10.16 Midpoint [numeric.ops.midpoint]
template<class T>
constexpr T midpoint(T a, T b) noexcept;
// Constraints: T is an arithmetic type other than bool.
// Returns: Half the sum of a and b. If T is an integer type and the sum is odd, the result is roundedtowards a.
// Remarks: No overflow occurs. If T is a floating-point type, at most one inexact operation occurs.
template<class T>
constexpr T* midpoint(T* a, T* b);
// Constraints: T is an object type.
// Mandates: T is a complete type.
// Preconditions: a and b point to, respectively, elements i and j of the same array object x.
// [Note 1: As specified in 6.8.3, an object that is not an array element is considered to belong to a single-element array for this purpose and a pointer past the last element of an array of n elements is considered to be equivalent to a pointer to a hypothetical array element n for this purpose.
// Returns: A pointer to array element i + j−i of x, where the result of the division is truncated towards 2 zero.
int main() {
    cout  <<  n4910 << endl;
           return EXIT_SUCCESS;
}

編纂・実行結果(compile and go)

bash
$ clang++ p1252.cpp -std=03 -o p1252l -I. -Wall
In file included from p1252.cpp:11:
In file included from ./N4910.h:11:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/atomic:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
 ^
p1252.cpp:23:3: error: unknown type name 'constexpr'
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
  ^
p1252.cpp:23:13: warning: variable templates are a C++14 extension [-Wc++14-extensions]
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
            ^
p1252.cpp:23:14: error: expected ';' at end of declaration
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
             ^
             ;
p1252.cpp:23:26: error: unknown type name 'InputIterator'
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
                         ^
p1252.cpp:23:47: error: unknown type name 'InputIterator'
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
                                              ^
p1252.cpp:23:67: error: unknown type name 'T'
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
                                                                  ^
p1252.cpp:23:15: error: C++ requires a type specifier for all declarations
  constexpr T accumulate(InputIterator first, InputIterator last, T init);
              ^
p1252.cpp:25:3: error: unknown type name 'constexpr'
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
  ^
p1252.cpp:25:13: warning: variable templates are a C++14 extension [-Wc++14-extensions]
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
            ^
p1252.cpp:25:14: error: expected ';' at end of declaration
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
             ^
             ;
p1252.cpp:25:26: error: unknown type name 'InputIterator'
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
                         ^
p1252.cpp:25:47: error: unknown type name 'InputIterator'
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
                                              ^
p1252.cpp:25:67: error: unknown type name 'T'
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
                                                                  ^
p1252.cpp:26:1: error: unknown type name 'BinaryOperation'
BinaryOperation binary_op);
^
p1252.cpp:25:15: error: C++ requires a type specifier for all declarations
  constexpr T accumulate(InputIterator first, InputIterator last, T init,
              ^
p1252.cpp:32:1: error: expected unqualified-id
template<class InputIterator>
^
p1252.cpp:36:1: error: expected unqualified-id
return reduce(first, last,
^
p1252.cpp:38:8: error: unknown type name 'ExecutionPolicy'
reduce(ExecutionPolicy&& exec,
       ^
p1252.cpp:38:23: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
reduce(ExecutionPolicy&& exec,
                      ^
p1252.cpp:39:8: error: unknown type name 'ForwardIterator'
       ForwardIterator first, ForwardIterator last);
       ^
p1252.cpp:39:31: error: unknown type name 'ForwardIterator'
       ForwardIterator first, ForwardIterator last);
                              ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.
$ clang++ p1252.cpp -std=2b -o p1252l -I. -Wall
p1252.cpp:32:1: error: expected unqualified-id
template<class InputIterator>
^
p1252.cpp:36:1: error: expected unqualified-id
return reduce(first, last,
^
p1252.cpp:38:8: error: unknown type name 'ExecutionPolicy'
reduce(ExecutionPolicy&& exec,
       ^
p1252.cpp:39:8: error: unknown type name 'ForwardIterator'
       ForwardIterator first, ForwardIterator last);
       ^
p1252.cpp:39:31: error: unknown type name 'ForwardIterator'
       ForwardIterator first, ForwardIterator last);
                              ^
p1252.cpp:38:1: error: C++ requires a type specifier for all declarations
reduce(ExecutionPolicy&& exec,
^
p1252.cpp:41:1: error: expected unqualified-id
return reduce(std::forward<ExecutionPolicy>(exec), first, last,
^
p1252.cpp:46:1: error: expected unqualified-id
return reduce(first, last, init, plus<>());
^
p1252.cpp:51:1: error: expected unqualified-id
return reduce(std::forward<ExecutionPolicy>(exec), first, last, init, plus<>());
^
p1252.cpp:69:1: error: unknown type name 'T'
T transform_reduce(ExecutionPolicy&& exec,
^
p1252.cpp:69:20: error: unknown type name 'ExecutionPolicy'
T transform_reduce(ExecutionPolicy&& exec,
                   ^
p1252.cpp:70:20: error: unknown type name 'ForwardIterator1'
                   ForwardIterator1 first1, ForwardIterator1 last1,
                   ^
p1252.cpp:70:45: error: unknown type name 'ForwardIterator1'
                   ForwardIterator1 first1, ForwardIterator1 last1,
                                            ^
p1252.cpp:71:20: error: unknown type name 'ForwardIterator2'
                   ForwardIterator2 first2,
                   ^
p1252.cpp:72:20: error: unknown type name 'T'
                   T init,
                   ^
p1252.cpp:73:20: error: unknown type name 'BinaryOperation1'
                   BinaryOperation1 binary_op1,
                   ^
p1252.cpp:74:20: error: unknown type name 'BinaryOperation2'
                   BinaryOperation2 binary_op2);
                   ^
p1252.cpp:93:1: error: expected unqualified-id
return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
^
p1252.cpp:101:1: error: expected unqualified-id
return transform_reduce(std::forward<ExecutionPolicy>(exec),
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1252.cpp -std=03 -o p1252g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1252.cpp:11:
/usr/local/include/c++/12.1.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   32 | #error This file requires compiler and library support \
      |  ^~~~~
p1252.cpp:23:3: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   23 |   constexpr T accumulate(InputIterator first, InputIterator last, T init);
      |   ^~~~~~~~~
p1252.cpp:372:34: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
  372 |   constexpr T midpoint(T a, T b) noexcept;
      |                                  ^~~~~~~~
p1252.cpp:23:3: error: 'constexpr' does not name a type
   23 |   constexpr T accumulate(InputIterator first, InputIterator last, T init);
      |   ^~~~~~~~~
p1252.cpp:23:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:25:3: error: 'constexpr' does not name a type
   25 |   constexpr T accumulate(InputIterator first, InputIterator last, T init,
      |   ^~~~~~~~~
p1252.cpp:25:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:32:1: error: expected unqualified-id before 'template'
   32 | template<class InputIterator>
      | ^~~~~~~~
p1252.cpp:36:1: error: expected unqualified-id before 'return'
   36 | return reduce(first, last,
      | ^~~~~~
p1252.cpp:37:75: error: expected unqualified-id before ')' token
   37 |                      typename iterator_traits<InputIterator>::value_type{});
      |                                                                           ^
p1252.cpp:38:7: error: expected constructor, destructor, or type conversion before '(' token
   38 | reduce(ExecutionPolicy&& exec,
      |       ^
p1252.cpp:41:1: error: expected unqualified-id before 'return'
   41 | return reduce(std::forward<ExecutionPolicy>(exec), first, last,
      | ^~~~~~
p1252.cpp:42:73: error: expected unqualified-id before ')' token
   42 |                  typename iterator_traits<ForwardIterator>::value_type{});
      |                                                                         ^
p1252.cpp:44:3: error: 'constexpr' does not name a type
   44 |   constexpr T reduce(InputIterator first, InputIterator last, T init);
      |   ^~~~~~~~~
p1252.cpp:44:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:46:1: error: expected unqualified-id before 'return'
   46 | return reduce(first, last, init, plus<>());
      | ^~~~~~
p1252.cpp:48:27: error: expected ',' or '...' before '&&' token
   48 |   T reduce(ExecutionPolicy&& exec,
      |                           ^~
p1252.cpp:51:1: error: expected unqualified-id before 'return'
   51 | return reduce(std::forward<ExecutionPolicy>(exec), first, last, init, plus<>());
      | ^~~~~~
p1252.cpp:53:3: error: 'constexpr' does not name a type
   53 |   constexpr T reduce(InputIterator first, InputIterator last, T init,
      |   ^~~~~~~~~
p1252.cpp:53:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:56:25: error: expected ',' or '...' before '&&' token
   56 | T reduce(ExecutionPolicy&& exec,
      |                         ^~
p1252.cpp:67:3: error: 'constexpr' does not name a type
   67 |   constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
      |   ^~~~~~~~~
p1252.cpp:67:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:69:1: error: 'T' does not name a type
   69 | T transform_reduce(ExecutionPolicy&& exec,
      | ^
p1252.cpp:82:3: error: 'constexpr' does not name a type
   82 |   constexpr T inner_product(InputIterator1 first1, InputIterator1 last1,
      |   ^~~~~~~~~
p1252.cpp:82:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:90:3: error: 'constexpr' does not name a type
   90 |   constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
      |   ^~~~~~~~~
p1252.cpp:90:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:93:1: error: expected unqualified-id before 'return'
   93 | return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
      | ^~~~~~
p1252.cpp:96:35: error: expected ',' or '...' before '&&' token
   96 | T transform_reduce(ExecutionPolicy&& exec,
      |                                   ^~
p1252.cpp:101:1: error: expected unqualified-id before 'return'
  101 | return transform_reduce(std::forward<ExecutionPolicy>(exec),
      | ^~~~~~
p1252.cpp:105:3: error: 'constexpr' does not name a type
  105 |   constexpr T transform_reduce(InputIterator1 first1, InputIterator1 last1,
      |   ^~~~~~~~~
p1252.cpp:105:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:118:16: error: expected constructor, destructor, or type conversion before '(' token
  118 | GENERALIZED_SUM(binary_op1, init, binary_op2(*i, *(first2 + (i - first1))), ...) for every iterator i in [first1, last1).
      |                ^
p1252.cpp:135:3: error: 'constexpr' does not name a type
  135 |   constexpr T transform_reduce(InputIterator first, InputIterator last, T init,
      |   ^~~~~~~~~
p1252.cpp:135:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:138:42: error: expected identifier before '[' token
  138 |          class ForwardIterator, class T, [first, last].
      |                                          ^
p1252.cpp:138:43: error: 'first' was not declared in this scope
  138 |          class ForwardIterator, class T, [first, last].
      |                                           ^~~~~
p1252.cpp:138:48: error: expected ']' before ',' token
  138 |          class ForwardIterator, class T, [first, last].
      |                                                ^
      |                                                ]
p1252.cpp:138:50: error: 'last' has not been declared
  138 |          class ForwardIterator, class T, [first, last].
      |                                                  ^~~~
p1252.cpp:138:54: error: expected '>' before ']' token
  138 |          class ForwardIterator, class T, [first, last].
      |                                                      ^
p1252.cpp:138:54: error: expected unqualified-id before ']' token
p1252.cpp:150:3: error: 'constexpr' does not name a type
  150 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:150:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:153:1: error: 'ForwardIterator2' does not name a type
  153 | ForwardIterator2
      | ^~~~~~~~~~~~~~~~
p1252.cpp:163:31: error: expected constructor, destructor, or type conversion before '(' token
  163 | GENERALIZED_NONCOMMUTATIVE_SUM( binary_op, init, *(first + 0), *(first + 1), ..., *(first + K - 1))
      |                               ^
p1252.cpp:176:1: error: expected unqualified-id before 'return'
  176 | return exclusive_scan(first, last, result, init, plus<>());
      | ^~~~~~
p1252.cpp:179:31: error: expected ',' or '...' before '&&' token
  179 | exclusive_scan(ExecutionPolicy&& exec,
      |                               ^~
p1252.cpp:183:1: error: expected unqualified-id before 'return'
  183 | return exclusive_scan(std::forward<ExecutionPolicy>(exec),
      | ^~~~~~
p1252.cpp:186:3: error: 'constexpr' does not name a type
  186 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:186:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:192:33: error: expected ',' or '...' before '&&' token
  192 |   inclusive_scan(ExecutionPolicy&& exec,
      |                                 ^~
p1252.cpp:204:1: error: expected unqualified-id before 'template'
  204 | template<class InputIterator, class OutputIterator>
      | ^~~~~~~~
p1252.cpp:209:1: error: expected unqualified-id before 'return'
  209 | return inclusive_scan(first, last, result, plus<>());
      | ^~~~~~
p1252.cpp:210:15: error: expected constructor, destructor, or type conversion before '(' token
  210 | inclusive_scan(ExecutionPolicy&& exec,
      |               ^
p1252.cpp:214:1: error: expected unqualified-id before 'return'
  214 | return inclusive_scan(std::forward<ExecutionPolicy>(exec), first, last, result, plus<>());
      | ^~~~~~
p1252.cpp:216:3: error: 'constexpr' does not name a type
  216 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:216:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:222:35: error: expected ',' or '...' before '&&' token
  222 |     inclusive_scan(ExecutionPolicy&& exec,
      |                                   ^~
p1252.cpp:226:3: error: 'constexpr' does not name a type
  226 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:226:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:231:31: error: expected constructor, destructor, or type conversion before '(' token
  231 | GENERALIZED_NONCOMMUTATIVE_SUM(
      |                               ^
p1252.cpp:259:3: error: 'constexpr' does not name a type
  259 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:259:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:267:3: error: expected 'class' or 'typename' before 'constexpr'
  267 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:267:13: error: expected '>' before 'OutputIterator'
  267 |   constexpr OutputIterator
      |             ^~~~~~~~~~~~~~
p1252.cpp:270:81: error: expected unqualified-id before ';' token
  270 |                              BinaryOperation binary_op, UnaryOperation unary_op);
      |                                                                                 ^
p1252.cpp:275:45: error: expected ',' or '...' before '&&' token
  275 |     transform_inclusive_scan(ExecutionPolicy&& exec,
      |                                             ^~
p1252.cpp:281:3: error: 'constexpr' does not name a type
  281 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:281:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:290:45: error: expected ',' or '...' before '&&' token
  290 |     transform_inclusive_scan(ExecutionPolicy&& exec,
      |                                             ^~
p1252.cpp:304:22: error: expected constructor, destructor, or type conversion before '(' token
  304 |              unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K)))
      |                      ^
p1252.cpp:316:40: error: expected ',' or '...' before '&&' token
  316 |     adjacent_difference(ExecutionPolicy&& exec,
      |                                        ^~
p1252.cpp:319:3: error: 'constexpr' does not name a type
  319 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:319:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:325:40: error: expected ',' or '...' before '&&' token
  325 |     adjacent_difference(ExecutionPolicy&& exec,
      |                                        ^~
p1252.cpp:340:3: error: 'constexpr' does not name a type
  340 |   constexpr void iota(ForwardIterator first, ForwardIterator last, T value);
      |   ^~~~~~~~~
p1252.cpp:340:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:344:10: error: 'input_or_output_iterator' has not been declared
  344 | template<input_or_output_iterator O, sentinel_for<O> S, weakly_incrementable T>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
p1252.cpp:344:38: error: 'sentinel_for' has not been declared
  344 | template<input_or_output_iterator O, sentinel_for<O> S, weakly_incrementable T>
      |                                      ^~~~~~~~~~~~
p1252.cpp:344:50: error: expected '>' before '<' token
  344 | template<input_or_output_iterator O, sentinel_for<O> S, weakly_incrementable T>
      |                                                  ^
p1252.cpp:345:3: error: 'requires' does not name a type
  345 |   requires indirectly_writable<O, const T&>
      |   ^~~~~~~~
p1252.cpp:345:3: note: 'requires' only available with '-std=c++20' or '-fconcepts'
p1252.cpp:347:10: error: 'weakly_incrementable' has not been declared
  347 | template<weakly_incrementable T, output_range<const T&> R>
      |          ^~~~~~~~~~~~~~~~~~~~
p1252.cpp:347:34: error: 'output_range' has not been declared
  347 | template<weakly_incrementable T, output_range<const T&> R>
      |                                  ^~~~~~~~~~~~
p1252.cpp:347:46: error: expected '>' before '<' token
  347 | template<weakly_incrementable T, output_range<const T&> R>
      |                                              ^
p1252.cpp:348:3: error: 'constexpr' does not name a type
  348 |   constexpr ranges::iota_result<borrowed_iterator_t<R>, T> ranges::iota(R&& r, T value);
      |   ^~~~~~~~~
p1252.cpp:348:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:350:8: error: expected unqualified-id before 'while'
  350 |        while (first != last) {
      |        ^~~~~
p1252.cpp:355:8: error: expected unqualified-id before 'return'
  355 |        return {std::move(first), std::move(value)};
      |        ^~~~~~
p1252.cpp:362:3: error: 'constexpr' does not name a type
  362 |   constexpr common_type_t<M, N> gcd(M m, N n);
      |   ^~~~~~~~~
p1252.cpp:362:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:366:3: error: 'constexpr' does not name a type
  366 |   constexpr common_type_t<M, N> lcm(M m, N n);
      |   ^~~~~~~~~
p1252.cpp:366:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:372:3: error: 'constexpr' does not name a type
  372 |   constexpr T midpoint(T a, T b) noexcept;
      |   ^~~~~~~~~
p1252.cpp:372:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1252.cpp:377:3: error: 'constexpr' does not name a type
  377 |   constexpr T* midpoint(T* a, T* b);
      |   ^~~~~~~~~
p1252.cpp:377:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'

$ g++ p1252.cpp -std=2b -o p1252g -I. -Wall
p1252.cpp:32:1: error: expected unqualified-id before 'template'
   32 | template<class InputIterator>
      | ^~~~~~~~
p1252.cpp:36:1: error: expected unqualified-id before 'return'
   36 | return reduce(first, last,
      | ^~~~~~
p1252.cpp:37:75: error: expected unqualified-id before ')' token
   37 |                      typename iterator_traits<InputIterator>::value_type{});
      |                                                                           ^
p1252.cpp:38:7: error: expected constructor, destructor, or type conversion before '(' token
   38 | reduce(ExecutionPolicy&& exec,
      |       ^
p1252.cpp:41:1: error: expected unqualified-id before 'return'
   41 | return reduce(std::forward<ExecutionPolicy>(exec), first, last,
      | ^~~~~~
p1252.cpp:42:73: error: expected unqualified-id before ')' token
   42 |                  typename iterator_traits<ForwardIterator>::value_type{});
      |                                                                         ^
p1252.cpp:46:1: error: expected unqualified-id before 'return'
   46 | return reduce(first, last, init, plus<>());
      | ^~~~~~
p1252.cpp:51:1: error: expected unqualified-id before 'return'
   51 | return reduce(std::forward<ExecutionPolicy>(exec), first, last, init, plus<>());
      | ^~~~~~
p1252.cpp:69:1: error: 'T' does not name a type
   69 | T transform_reduce(ExecutionPolicy&& exec,
      | ^
p1252.cpp:93:1: error: expected unqualified-id before 'return'
   93 | return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>());
      | ^~~~~~
p1252.cpp:101:1: error: expected unqualified-id before 'return'
  101 | return transform_reduce(std::forward<ExecutionPolicy>(exec),
      | ^~~~~~
p1252.cpp:118:16: error: expected constructor, destructor, or type conversion before '(' token
  118 | GENERALIZED_SUM(binary_op1, init, binary_op2(*i, *(first2 + (i - first1))), ...) for every iterator i in [first1, last1).
      |                ^
p1252.cpp:138:42: error: expected identifier before '[' token
  138 |          class ForwardIterator, class T, [first, last].
      |                                          ^
p1252.cpp:138:43: error: 'first' was not declared in this scope
  138 |          class ForwardIterator, class T, [first, last].
      |                                           ^~~~~
p1252.cpp:138:48: error: expected ']' before ',' token
  138 |          class ForwardIterator, class T, [first, last].
      |                                                ^
      |                                                ]
p1252.cpp:138:50: error: 'last' has not been declared
  138 |          class ForwardIterator, class T, [first, last].
      |                                                  ^~~~
p1252.cpp:138:54: error: expected '>' before ']' token
  138 |          class ForwardIterator, class T, [first, last].
      |                                                      ^
p1252.cpp:138:54: error: expected unqualified-id before ']' token
p1252.cpp:153:1: error: 'ForwardIterator2' does not name a type
  153 | ForwardIterator2
      | ^~~~~~~~~~~~~~~~
p1252.cpp:163:31: error: expected constructor, destructor, or type conversion before '(' token
  163 | GENERALIZED_NONCOMMUTATIVE_SUM( binary_op, init, *(first + 0), *(first + 1), ..., *(first + K - 1))
      |                               ^
p1252.cpp:176:1: error: expected unqualified-id before 'return'
  176 | return exclusive_scan(first, last, result, init, plus<>());
      | ^~~~~~
p1252.cpp:183:1: error: expected unqualified-id before 'return'
  183 | return exclusive_scan(std::forward<ExecutionPolicy>(exec),
      | ^~~~~~
p1252.cpp:204:1: error: expected unqualified-id before 'template'
  204 | template<class InputIterator, class OutputIterator>
      | ^~~~~~~~
p1252.cpp:209:1: error: expected unqualified-id before 'return'
  209 | return inclusive_scan(first, last, result, plus<>());
      | ^~~~~~
p1252.cpp:210:15: error: expected constructor, destructor, or type conversion before '(' token
  210 | inclusive_scan(ExecutionPolicy&& exec,
      |               ^
p1252.cpp:214:1: error: expected unqualified-id before 'return'
  214 | return inclusive_scan(std::forward<ExecutionPolicy>(exec), first, last, result, plus<>());
      | ^~~~~~
p1252.cpp:231:31: error: expected constructor, destructor, or type conversion before '(' token
  231 | GENERALIZED_NONCOMMUTATIVE_SUM(
      |                               ^
p1252.cpp:267:3: error: expected 'class' or 'typename' before 'constexpr'
  267 |   constexpr OutputIterator
      |   ^~~~~~~~~
p1252.cpp:267:3: error: expected identifier before 'constexpr'
p1252.cpp:267:3: error: expected '>' before 'constexpr'
p1252.cpp:270:81: error: expected unqualified-id before ';' token
  270 |                              BinaryOperation binary_op, UnaryOperation unary_op);
      |                                                                                 ^
p1252.cpp:304:22: error: expected constructor, destructor, or type conversion before '(' token
  304 |              unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K)))
      |                      ^
p1252.cpp:346:21: error: 'iota_result' in namespace 'std::ranges' does not name a template type; did you mean 'move_result'?
  346 |   constexpr ranges::iota_result<O, T> ranges::iota(O first, S last, T value);
      |                     ^~~~~~~~~~~
      |                     move_result
p1252.cpp:347:34: error: 'output_range' has not been declared
  347 | template<weakly_incrementable T, output_range<const T&> R>
      |                                  ^~~~~~~~~~~~
p1252.cpp:347:46: error: expected '>' before '<' token
  347 | template<weakly_incrementable T, output_range<const T&> R>
      |                                              ^
p1252.cpp:348:21: error: 'iota_result' in namespace 'std::ranges' does not name a template type; did you mean 'move_result'?
  348 |   constexpr ranges::iota_result<borrowed_iterator_t<R>, T> ranges::iota(R&& r, T value);
      |                     ^~~~~~~~~~~
      |                     move_result
p1252.cpp:350:8: error: expected unqualified-id before 'while'
  350 |        while (first != last) {
      |        ^~~~~
p1252.cpp:355:8: error: expected unqualified-id before 'return'
  355 |        return {std::move(first), std::move(value)};
      |        ^~~~~~

検討事項(agenda)

コンパイルエラーを取るか、コンパイルエラーの理由を解説する。

応用例1 AUTOSAR C++

AUTOSARでC++のコーディング標準を作っている。 
MISRA-C++コーディング標準の改訂をまたずに、C++14に対応したかったためかもしれない。 

Autosar Guidelines C++14 example code compile list

応用例2 MISRA C++

MISRA C++, AUTOSAR C++について

MISRA C++ 5-0-16

応用例3 CERT C++

MISRA C/C++, AUTOSAR C++, CERT C/C++とC/C++工業標準をコンパイルする

応用例4 箱庭 

箱庭ではUnityをはじめC++を使っているらしい。 

ここでコンパイルしたコードと同じようなコードを使っているか、
ここで出たコンパイルエラーと同じようなエラーがでたかを
いろいろな版のコンパイラでコンパイルして確認していく。

仮想戦略会議「箱庭」

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる(1)

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる(2)

参考資料(reference)

エンジニア夏休み企画 個人開発

自己参考資料(self reference)

関連する自己参照以外は、こちらの先頭に移転。

C言語(C++)に対する誤解、曲解、無理解、爽快。

#include "N4910.h"

C++N4910資料の改善点

dockerにclang

docker gnu(gcc/g++) and llvm(clang/clang++)

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)

C++N4910:2022 tag follower 300人超えました。ありがとうございます。

astyle 使ってみた

【個人開発】 効率的な背景 <エンジニア夏休み企画>

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>

文書履歴(document history)

ver. 0.01 初稿  20220816

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0