Skip to content

Instantly share code, notes, and snippets.

C++20のseq_cst修復(P0668R5)をていねいに読む

調査日: 2026年10月15日

調査モデル : Opus 5.5

元記事: C++メモリモデルの変遷(C++11〜C++26)の「C++20 : seq_cstとリリースシーケンスの修復」節

この文書について

C++メモリモデルの変遷(C++11〜C++26)

調査日 : 2026年10月15日

調査モデル : Opus 5.5

C++のメモリモデルは、2007年に採択されたN2429を骨格として、C++11で初めて規格化された。その後の大きな変更は3つある。

  • C++14 : OOTAの禁止規定が、「避けるべきである」という勧告に弱められた(N3786)。
  • C++20 : seq_cstとフェンスの意味論が修復され(P0668R5)、リリースシーケンスが弱められた(P0982R1)。
@yohhoy
yohhoy / p2300-words.md
Last active September 24, 2025 01:05
C++26 std::execution paper size
Paper Title Words
P2300R10 std::execution 47495
P3325R5 A Utility for Creating Execution Environments 2168
P3396R1 std::execution wording fixes 3061
P2079R10 Parallel scheduler 9383
P3149R11 async_scope - Creating scopes for non-sequential concurrency 16255
P3284R4 write_env and unstoppable Sender Adaptors 1346
P3433R1 Allocator Support for Operation States 827
@yohhoy
yohhoy / cancellable-sender.cpp
Last active September 24, 2025 07:59
Cancellable sender in C++26 S/R library
#include <cassert>
#include <stop_token>
#include <utility>
#include <print>
// https://github.com/NVIDIA/stdexec/
#include <stdexec/execution.hpp>
namespace exec = stdexec;
namespace std {
using exec::get_stop_token, exec::sync_wait;
using exec::inplace_stop_source, exec::stoppable_token;
@yohhoy
yohhoy / awaitable-coroutine.cpp
Last active June 13, 2025 09:02
C++26 Sender/Receiver and awaitable Coroutine
#include <coroutine>
#include <print>
// https://github.com/NVIDIA/stdexec/
#include <stdexec/execution.hpp>
namespace ex = stdexec;
template<typename T>
class Lazy {
public:
@yohhoy
yohhoy / submdspan-test.cpp
Created January 31, 2024 14:19
submdspan
#include <cassert>
#include <concepts>
#include <span>
#include <tuple>
#include <utility>
#include <ranges>
#if 1
#include <https://raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp>
#else
#include <mdspan>
@yohhoy
yohhoy / mdspan_hilbert.cpp
Last active November 25, 2023 17:07
Hilbert curve layout for std::mdspan
#include <cassert>
#include <bit>
#include <iostream>
#include <utility>
#if 1
#include <https://raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp>
using std::experimental::mdspan;
using std::experimental::dextents;
#else
#include <mdspan>
@yohhoy
yohhoy / mdspan-test.cpp
Last active May 2, 2024 07:22
mdspan constructors & deduction guides
#include <cassert>
#include <array>
#include <span>
#include <type_traits>
#if 0
#include <mdspan>
#else
#include <https://raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp>
#endif
using namespace std;
@yohhoy
yohhoy / mm.c
Last active September 22, 2022 04:44
// https://groups.google.com/g/golang-nuts/c/Gze1TRtdLdc/m/RoD2AxssDgAJ
// http://svr-pes20-cppmem.cl.cam.ac.uk/cppmem/
int main() {
int x = 0;
atomic_int int y = 0;
{{{ { x = 1;
y.store(1);
x = 1;
y.store(1); }
||| { y.load().readsvalue(0);

Full barrier

P: =p0=\ /----\ /=p1=\ /----\ /=
        *      *      *      *
C: ----/ \=c0=/ \----/ \=c1=/ \-

Half barrier

P: p0=\--------/=p1=\--------/=