diff --git a/public/og/return-std-move-const-copy.png b/public/og/return-std-move-const-copy.png new file mode 100644 index 00000000..8f4a1a4f Binary files /dev/null and b/public/og/return-std-move-const-copy.png differ diff --git a/social/facebook/return-std-move-const-copy/README.md b/social/facebook/return-std-move-const-copy/README.md new file mode 100644 index 00000000..85dc2af2 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/README.md @@ -0,0 +1,130 @@ +# LinkedIn Square Post (1200x1200) + +Standard LinkedIn feed post at 1:1 square aspect ratio. Works well as a scroll-stopping image in the LinkedIn feed. + +## Usage + +```bash +brand-gen init social/linkedin-post my-post +cd my-post +# edit content.md +brand-gen build # -> index.html +brand-gen image # -> my-post.png (2400x2400 at 2x DPR) +``` + +## Directives + +All templates use one of four post types. Each uses the same directive pattern: + +### Quote + +```markdown +::::post{type=quote theme=dark logo=top-left} + +:::quote{author="Filip Sajdak" role="Founder & CEO, ScudoAI"} + +Sovereign AI is not a feature you bolt on later. It is the architecture. + +::: + +:::: +``` + +### Stat + +```markdown +::::post{type=stat theme=light accent=brand} + +:::stat{value="USD 80B" label="Worldwide sovereign cloud spend" context="Europe is the fastest-growing region at 83% YoY." source="Gartner, Feb 2026"} +::: + +:::: +``` + +### Announcement + +```markdown +::::post{type=announcement theme=light} + +:::announcement{kind="launch" date="April 2026"} + +# ScudoAI joins NVIDIA Inception + +We are thrilled to join the NVIDIA Inception program to accelerate sovereign AI deployment across European regulated industries. + +::: + +:::: +``` + +### Insight + +```markdown +::::post{type=insight theme=dark} + +:::insight{citation="EU AI Act full enforcement: 2 August 2026"} + +# The AI compliance deadline most companies are missing + +Full EU AI Act enforcement for high-risk AI systems begins in 2 August 2026. Most regulated enterprises are not ready for the documentation and audit requirements. Teams running cloud AI will face the hardest transition. + +::: + +:::: +``` + +## Attributes reference + +### `::::post` attributes + +- `type` - quote | stat | announcement | insight (required) +- `theme` - dark | light (default light) +- `accent` - brand | amber | nv (optional colored gradient background) +- `logo` - top-left | top-right | bottom-left | bottom-right (default bottom-right) + +### `:::quote` attributes + +- `author` - attribution name (appears below the quote) +- `role` - attribution role/title (appears under the author) + +### `:::stat` attributes + +- `value` - the big number (e.g. "USD 80B", "3/4", "Hours to minutes") +- `label` - short label under the value +- `context` - 1-2 sentences providing context +- `source` - small citation + +### `:::announcement` attributes + +- `kind` - launch | milestone | event | hire | partnership +- `date` - free-form date string + +### `:::insight` attributes + +- `citation` - small footer citation (e.g. regulation reference) + +## Character limits + +- **Quote body**: ~120 characters for maximum readability at thumbnail size +- **Stat label**: ~40 characters +- **Stat context**: ~200 characters +- **Announcement headline**: ~80 characters +- **Announcement body**: ~250 characters +- **Insight hook**: ~100 characters +- **Insight body**: ~300 characters + +Posts that exceed these limits will still render but typography may shrink or content may clip. + +## Media + +Add a `media/` directory to the project and reference local files: + +```markdown +:::background{image="nvidia-thor.jpg" overlay="dark"} +::: + +:::image{src="product-screenshot.png" alt="ScudoAI compliance dashboard" position="top"} +::: +``` + +Paths are relative to the project's `media/` directory. diff --git a/social/facebook/return-std-move-const-copy/assets/brand-kit.json b/social/facebook/return-std-move-const-copy/assets/brand-kit.json new file mode 100644 index 00000000..161a5c72 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/assets/brand-kit.json @@ -0,0 +1,11 @@ +{ + "template": "social/linkedin-post", + "bundleSource": "scudoai-social.css", + "brandKitVersion": "0.1.0", + "vendoredAt": "2026-11-17T23:57:03.247Z", + "files": [ + "scudoai.css", + "layout.css", + "logo-symbol.svg" + ] +} diff --git a/social/facebook/return-std-move-const-copy/assets/layout.css b/social/facebook/return-std-move-const-copy/assets/layout.css new file mode 100644 index 00000000..e69de29b diff --git a/social/facebook/return-std-move-const-copy/assets/logo-symbol.svg b/social/facebook/return-std-move-const-copy/assets/logo-symbol.svg new file mode 100644 index 00000000..1fc44966 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/assets/logo-symbol.svg @@ -0,0 +1,22 @@ + diff --git a/social/facebook/return-std-move-const-copy/assets/scudoai.css b/social/facebook/return-std-move-const-copy/assets/scudoai.css new file mode 100644 index 00000000..612b5a12 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/assets/scudoai.css @@ -0,0 +1,343 @@ +/* ============================================================ + * wro.cpp social card -- standalone stylesheet + * + * Self-contained styling for brand-gen's `social/linkedin-post` + * output. Replaces (does NOT extend) the scudoai-social.css that + * brand-gen ships with -- the design language here is the + * wro.cpp 'Editorial Magnet' look used by src/styles/global.css, + * not the scudoai blue-indigo deck aesthetic. + * + * Source of truth for tokens: src/styles/global.css:12-30 in the + * wrocpp.github.io repo. + * + * Brand-gen markup we style: + *
+ *
(decorative, hidden) + *
(decorative, hidden) + *
+ *

...

+ *

...

+ *
...
+ *
+ *
+ * + * ScudoAI (hidden; replaced via ::after) + *
+ *
+ * + * Other card types (card-quote, card-stat, card-announcement) + * get analogous rules at the bottom. + * ============================================================ */ + +@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;500;700&display=swap'); + +:root { + --paper: #FCFAF5; + --paper-2: #F3EFE6; + --paper-3: #E8E1D0; + --ink: #1B1B1D; + --ink-muted:#55555A; + --ink-faint:#8A8A90; + --rule: #D7D2C4; + --orange: #EA541E; + --orange-2: #D6481A; + --blue: #3EB5E9; + --blue-deep:#2E8FB8; + + --font-display: 'Quicksand', system-ui, -apple-system, sans-serif; + --font-body: 'Source Serif 4', Georgia, serif; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; +} + +html, body { + margin: 0; + padding: 0; + background: var(--paper); + color: var(--ink); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: var(--font-body); + font-size: 18px; + line-height: 1.6; +} + +/* Hide brand-gen decorative noise -- the wro.cpp aesthetic is calm + * and editorial, not a dark deck with glow + grid backgrounds. */ +.grid-bg, .glow { display: none !important; } + +/* ---------------- Card frame (1200x1200) ---------------- */ +.card { + position: relative; + width: 1200px; + height: 1200px; + background: var(--paper); + /* Faint warm radial wash, mirrors body { background-image } in + * src/styles/global.css:44-49 -- gives the paper texture without + * looking flat. */ + background-image: + radial-gradient(900px 700px at 80% -10%, rgba(234, 84, 30, 0.06), transparent 60%), + radial-gradient(800px 600px at -10% 110%, rgba(62, 181, 233, 0.05), transparent 60%); + overflow: hidden; + box-sizing: border-box; + padding: 130px 110px 130px 110px; + display: flex; + flex-direction: column; + /* Faint inner border gives the card a printed-page feel. */ + border-bottom: 6px solid var(--orange); +} + +/* Override: theme=dark cards still use paper. We keep the editorial + * light look across the board so the wro.cpp brand stays consistent. + * If the user really wants a dark variant later, this is the hook. */ +.card.dark { background: var(--paper) !important; color: var(--ink) !important; } +.card.dark h1, .card.dark h2, .card.dark p, +.card.dark blockquote { color: var(--ink) !important; } + +/* ---------------- INSIGHT card ---------------- */ +.card-insight { + justify-content: center; + padding-top: 200px; /* reserve space for logo watermark (top:90px + 64px + safety) */ +} +.card-insight .insight-content { + display: flex; + flex-direction: column; + gap: 60px; + max-width: 980px; +} +.card-insight h1 { + font-family: var(--font-display); + font-weight: 700; + font-size: 92pt; + line-height: 1.02; + letter-spacing: -0.025em; + color: var(--ink); + margin: 0; +} +.card-insight h1.title-long { + font-size: 72pt; + line-height: 1.06; + letter-spacing: -0.02em; + max-height: 420px; +} +.card-insight h1.title-xlong { + font-size: 56pt; + line-height: 1.10; + letter-spacing: -0.015em; + max-height: 440px; +} +/* Auto-accent: ++ in C++/C++26 turns orange, sentence-final period + * (when wrapped in ) turns blue. The skill writes + * the heading with these spans for the wro.cpp signature look. */ +.card-insight h1 .accent { color: var(--orange); } +.card-insight h1 .dot { color: var(--blue-deep); } +.card-insight p { + font-family: var(--font-body); + font-size: 30pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 0; + max-width: 920px; +} +.card-insight .insight-citation { + font-family: var(--font-mono); + font-size: 18pt; + letter-spacing: 0.04em; + color: var(--ink-faint); + margin-top: 40px; + padding-top: 30px; + border-top: 1px solid var(--rule); + text-transform: lowercase; +} +.card-insight .insight-citation::before { + content: '// '; + color: var(--orange); + font-weight: 700; +} + +/* ---------------- QUOTE card ---------------- */ +.card-quote { justify-content: center; padding: 140px 110px; } +.card-quote .quote-content { display: flex; flex-direction: column; align-items: flex-start; } +.card-quote .quote-mark { + font-family: var(--font-display); + font-weight: 700; + font-size: 200pt; + line-height: 0.8; + color: var(--orange); + opacity: 0.20; + /* In-flow above the text (not floated in the corner) with a negative + * bottom margin so the mark nearly touches the first quote line. */ + margin: 0 0 -0.62em; +} +.card-quote .quote-body { + font-family: var(--font-display); + font-weight: 600; + font-size: 64pt; + line-height: 1.15; + letter-spacing: -0.02em; + color: var(--ink); + max-width: 980px; + margin: 0; +} +.card-quote .quote-attribution { + margin-top: 50px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-muted); +} +.card-quote .quote-attribution::before { content: '-- '; color: var(--orange); } +/* author and role are adjacent spans with no separator in the markup; + * add one so they do not run together ("wro.cppC++26 ..."). */ +.card-quote .quote-attribution .role::before { content: ' / '; color: var(--ink-faint); } + +/* ---------------- STAT card ---------------- */ +.card-stat { justify-content: center; } +/* Value and label sit side by side (label wraps to stacked lines whose + * combined height roughly matches the value); context + source span the + * full width underneath. */ +.card-stat .stat-content { + display: grid; + grid-template-columns: auto 1fr; + grid-template-areas: + "value label" + "context context" + "source source"; + column-gap: 64px; + align-items: center; +} +.card-stat .stat-value { + grid-area: value; + font-family: var(--font-display); + font-weight: 700; + font-size: 240pt; + line-height: 0.82; + letter-spacing: -0.04em; + color: var(--orange); + margin: 0; +} +.card-stat .stat-label { + grid-area: label; + font-family: var(--font-display); + font-weight: 700; + font-size: 90pt; + line-height: 1.0; + letter-spacing: -0.02em; + color: var(--ink); + /* min-content forces a per-word wrap, so "codegen steps" stacks into + * two lines next to the value instead of running on one long line. */ + width: min-content; + margin: 0; +} +.card-stat .stat-context { + grid-area: context; + font-family: var(--font-body); + font-size: 26pt; + line-height: 1.45; + color: var(--ink-muted); + margin: 56px 0 0; + max-width: 880px; +} +.card-stat .stat-source { + grid-area: source; + margin-top: 44px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-faint); +} +.card-stat .stat-source::before { content: '// '; color: var(--orange); } + +/* ---------------- ANNOUNCEMENT card ---------------- */ +.card-announcement { justify-content: center; } +.card-announcement .announcement-meta { + font-family: var(--font-mono); + font-size: 20pt; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--orange); + margin-bottom: 30px; +} +.card-announcement .announcement-content h1, +.card-announcement .announcement-content h2 { + font-family: var(--font-display); + font-weight: 700; + font-size: 78pt; + line-height: 1.05; + letter-spacing: -0.02em; + color: var(--ink); + margin: 0; +} +.card-announcement .announcement-content p { + font-family: var(--font-body); + font-size: 28pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 40px 0 0; + max-width: 900px; +} + +/* ---------------- LOGO WATERMARK ---------------- */ +/* brand-gen hard-codes "ScudoAI" in .logo-wordmark; we hide it and + * draw "wro.cpp" via ::after on the watermark. The orange ".cpp" mirrors + * the brand-mark in the site header. */ +.logo-watermark { + position: absolute; + display: flex; + align-items: center; + gap: 18px; + height: 64px; + z-index: 10; + color: var(--ink); +} +.logo-watermark.top-left { top: 90px; left: 110px; } +.logo-watermark.top-right { top: 90px; right: 110px; } +.logo-watermark.bottom-left { bottom: 60px; left: 110px; } +.logo-watermark.bottom-right { bottom: 60px; right: 110px; } +.logo-watermark svg { + width: 64px; + height: 64px; + flex-shrink: 0; + /* Magnet logo PNG already has transparent paper-tone background; + * no rounded box needed -- it sits on the paper card directly. */ +} +.logo-wordmark { + font-size: 0 !important; + line-height: 0 !important; + /* Hide the upstream "ScudoAI" text node entirely. */ +} +.logo-watermark::after { + content: 'wro.cpp'; + font-family: var(--font-display); + font-weight: 700; + font-size: 28pt; + letter-spacing: -0.025em; + color: var(--ink); + line-height: 1; + /* The .cpp portion is given orange via a ::first-line trick below + * isn't reliable for inline -- so the SKILL writes the wordmark + * with explicit spans when it owns the markup. For this default + * rendering, the whole wordmark is ink and the orange comes through + * the bottom border + eyebrow. */ +} +.logo-watermark.top-right::after, +.logo-watermark.bottom-right::after { order: -1; margin-right: 18px; } + +/* ---------------- AI DISCLOSURE BADGE ---------------- */ +/* A small, honest "AI-GENERATED" label so the disclosure rides with the + * card image on social. Bottom-right corner (logo is top-left, citation is + * center-bottom, so this corner is free). Injected into index.html by + * inject.sh. See the /ai policy page. */ +.ai-badge { + position: absolute; + bottom: 74px; /* clears the 6px orange accent bar; sits in the bottom padding band */ + right: 110px; /* matches the card side padding / logo inset */ + z-index: 10; + font-family: var(--font-mono); + font-size: 14pt; + font-weight: 500; + letter-spacing: 0.10em; + text-transform: uppercase; + color: var(--ink-faint); +} + +/* ---------------- Defensive overrides ---------------- */ +/* Anything brand-gen might have set inline using its tokens. */ +* { box-sizing: border-box; } diff --git a/social/facebook/return-std-move-const-copy/caption.md b/social/facebook/return-std-move-const-copy/caption.md new file mode 100644 index 00000000..cb445f61 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/caption.md @@ -0,0 +1,22 @@ +# Moving a const object returns a copy: 163 page faults per call on a 400 KB vector + +## Body +return std::move(book) on a const local is a copy. + +std::move on a const object gives a const T&&, which only the copy constructor accepts. On GCC 16.2 a 400 KB const vector took 163 page faults per call, and a plain return took none. + +GCC and Clang warn about the const local with the same text they use for a harmless move. clang-tidy also flags two shapes they miss. By value for a string in a struct costs an allocation from 16 characters on libstdc++. + +All numbers come from programs of my own, run on Compiler Explorer. I have not seen the course advert that prompted this post. + +https://wrocpp.github.io/posts/return-std-move-const-copy/ + +## Hashtags +#cpp #cpp26 #movesemantics #copyelision #performance #wrocpp + +## Alt-text +wro.cpp card with the magnet logo. Headline reads "Move a const local and you copy 400 KB" with a subtitle about 163 page faults per call on GCC 16.2. Citation footer: wro.cpp, 2026-12-28. + +## Suggested post time +Monday 2026-12-28, 08:00 UTC +Reason: the morning slot on the publication day. diff --git a/social/facebook/return-std-move-const-copy/config.yaml b/social/facebook/return-std-move-const-copy/config.yaml new file mode 100644 index 00000000..e4148343 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/config.yaml @@ -0,0 +1,12 @@ +template: social/linkedin-post + +size: + width: 1200 + height: 1200 + dpr: 2 + +project: + name: "return-std-move-const-copy" + author: "Filip Sajdak, Founder & CEO" + email: "office@scudoai.com" + date: "2026-12-28" diff --git a/social/facebook/return-std-move-const-copy/content.md b/social/facebook/return-std-move-const-copy/content.md new file mode 100644 index 00000000..478931a1 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/content.md @@ -0,0 +1,12 @@ +--- +template: social/linkedin-post +--- + +::::post{type=insight theme=dark logo=top-left} + +:::insight{citation="wro.cpp -- 2026-12-28"} +# Move a const local and you copy 400 KB +On GCC 16.2 the const vector took 163 page faults per call, a plain return took none. Both compilers warn, with the text they give a harmless move. clang-tidy flags two shapes they miss. +::: + +:::: diff --git a/social/facebook/return-std-move-const-copy/image.png b/social/facebook/return-std-move-const-copy/image.png new file mode 100644 index 00000000..9eccdea4 Binary files /dev/null and b/social/facebook/return-std-move-const-copy/image.png differ diff --git a/social/facebook/return-std-move-const-copy/index.html b/social/facebook/return-std-move-const-copy/index.html new file mode 100644 index 00000000..535b6ed3 --- /dev/null +++ b/social/facebook/return-std-move-const-copy/index.html @@ -0,0 +1,28 @@ + + + + + + return-std-move-const-copy + + + + + + + + + + +

Move a const local and you copy 400 KB

On GCC 16.2 the const vector took 163 page faults per call, a plain return took none. Both compilers warn, with the text they give a harmless move. clang-tidy flags two shapes they miss.

wro.cpp -- 2026-12-28
ScudoAI
AI-generated
+ + \ No newline at end of file diff --git a/social/facebook/return-std-move-const-copy/media/.gitkeep b/social/facebook/return-std-move-const-copy/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/social/facebook/return-std-move-const-copy/media/README.md b/social/facebook/return-std-move-const-copy/media/README.md new file mode 100644 index 00000000..bb81c7fa --- /dev/null +++ b/social/facebook/return-std-move-const-copy/media/README.md @@ -0,0 +1,9 @@ +# Media directory + +Drop images here (PNG, JPG, SVG) for use in your post. + +Reference them in your content.md with: + + :::image{src="screenshot.png" alt="Alt text" position="top"} + +The renderer resolves paths relative to this media/ directory. diff --git a/social/linkedin/return-std-move-const-copy/README.md b/social/linkedin/return-std-move-const-copy/README.md new file mode 100644 index 00000000..85dc2af2 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/README.md @@ -0,0 +1,130 @@ +# LinkedIn Square Post (1200x1200) + +Standard LinkedIn feed post at 1:1 square aspect ratio. Works well as a scroll-stopping image in the LinkedIn feed. + +## Usage + +```bash +brand-gen init social/linkedin-post my-post +cd my-post +# edit content.md +brand-gen build # -> index.html +brand-gen image # -> my-post.png (2400x2400 at 2x DPR) +``` + +## Directives + +All templates use one of four post types. Each uses the same directive pattern: + +### Quote + +```markdown +::::post{type=quote theme=dark logo=top-left} + +:::quote{author="Filip Sajdak" role="Founder & CEO, ScudoAI"} + +Sovereign AI is not a feature you bolt on later. It is the architecture. + +::: + +:::: +``` + +### Stat + +```markdown +::::post{type=stat theme=light accent=brand} + +:::stat{value="USD 80B" label="Worldwide sovereign cloud spend" context="Europe is the fastest-growing region at 83% YoY." source="Gartner, Feb 2026"} +::: + +:::: +``` + +### Announcement + +```markdown +::::post{type=announcement theme=light} + +:::announcement{kind="launch" date="April 2026"} + +# ScudoAI joins NVIDIA Inception + +We are thrilled to join the NVIDIA Inception program to accelerate sovereign AI deployment across European regulated industries. + +::: + +:::: +``` + +### Insight + +```markdown +::::post{type=insight theme=dark} + +:::insight{citation="EU AI Act full enforcement: 2 August 2026"} + +# The AI compliance deadline most companies are missing + +Full EU AI Act enforcement for high-risk AI systems begins in 2 August 2026. Most regulated enterprises are not ready for the documentation and audit requirements. Teams running cloud AI will face the hardest transition. + +::: + +:::: +``` + +## Attributes reference + +### `::::post` attributes + +- `type` - quote | stat | announcement | insight (required) +- `theme` - dark | light (default light) +- `accent` - brand | amber | nv (optional colored gradient background) +- `logo` - top-left | top-right | bottom-left | bottom-right (default bottom-right) + +### `:::quote` attributes + +- `author` - attribution name (appears below the quote) +- `role` - attribution role/title (appears under the author) + +### `:::stat` attributes + +- `value` - the big number (e.g. "USD 80B", "3/4", "Hours to minutes") +- `label` - short label under the value +- `context` - 1-2 sentences providing context +- `source` - small citation + +### `:::announcement` attributes + +- `kind` - launch | milestone | event | hire | partnership +- `date` - free-form date string + +### `:::insight` attributes + +- `citation` - small footer citation (e.g. regulation reference) + +## Character limits + +- **Quote body**: ~120 characters for maximum readability at thumbnail size +- **Stat label**: ~40 characters +- **Stat context**: ~200 characters +- **Announcement headline**: ~80 characters +- **Announcement body**: ~250 characters +- **Insight hook**: ~100 characters +- **Insight body**: ~300 characters + +Posts that exceed these limits will still render but typography may shrink or content may clip. + +## Media + +Add a `media/` directory to the project and reference local files: + +```markdown +:::background{image="nvidia-thor.jpg" overlay="dark"} +::: + +:::image{src="product-screenshot.png" alt="ScudoAI compliance dashboard" position="top"} +::: +``` + +Paths are relative to the project's `media/` directory. diff --git a/social/linkedin/return-std-move-const-copy/assets/brand-kit.json b/social/linkedin/return-std-move-const-copy/assets/brand-kit.json new file mode 100644 index 00000000..efe54739 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/assets/brand-kit.json @@ -0,0 +1,11 @@ +{ + "template": "social/linkedin-post", + "bundleSource": "scudoai-social.css", + "brandKitVersion": "0.1.0", + "vendoredAt": "2026-11-17T23:57:03.147Z", + "files": [ + "scudoai.css", + "layout.css", + "logo-symbol.svg" + ] +} diff --git a/social/linkedin/return-std-move-const-copy/assets/layout.css b/social/linkedin/return-std-move-const-copy/assets/layout.css new file mode 100644 index 00000000..e69de29b diff --git a/social/linkedin/return-std-move-const-copy/assets/logo-symbol.svg b/social/linkedin/return-std-move-const-copy/assets/logo-symbol.svg new file mode 100644 index 00000000..1fc44966 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/assets/logo-symbol.svg @@ -0,0 +1,22 @@ + diff --git a/social/linkedin/return-std-move-const-copy/assets/scudoai.css b/social/linkedin/return-std-move-const-copy/assets/scudoai.css new file mode 100644 index 00000000..612b5a12 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/assets/scudoai.css @@ -0,0 +1,343 @@ +/* ============================================================ + * wro.cpp social card -- standalone stylesheet + * + * Self-contained styling for brand-gen's `social/linkedin-post` + * output. Replaces (does NOT extend) the scudoai-social.css that + * brand-gen ships with -- the design language here is the + * wro.cpp 'Editorial Magnet' look used by src/styles/global.css, + * not the scudoai blue-indigo deck aesthetic. + * + * Source of truth for tokens: src/styles/global.css:12-30 in the + * wrocpp.github.io repo. + * + * Brand-gen markup we style: + *
+ *
(decorative, hidden) + *
(decorative, hidden) + *
+ *

...

+ *

...

+ *
...
+ *
+ *
+ * + * ScudoAI (hidden; replaced via ::after) + *
+ *
+ * + * Other card types (card-quote, card-stat, card-announcement) + * get analogous rules at the bottom. + * ============================================================ */ + +@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;500;700&display=swap'); + +:root { + --paper: #FCFAF5; + --paper-2: #F3EFE6; + --paper-3: #E8E1D0; + --ink: #1B1B1D; + --ink-muted:#55555A; + --ink-faint:#8A8A90; + --rule: #D7D2C4; + --orange: #EA541E; + --orange-2: #D6481A; + --blue: #3EB5E9; + --blue-deep:#2E8FB8; + + --font-display: 'Quicksand', system-ui, -apple-system, sans-serif; + --font-body: 'Source Serif 4', Georgia, serif; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; +} + +html, body { + margin: 0; + padding: 0; + background: var(--paper); + color: var(--ink); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: var(--font-body); + font-size: 18px; + line-height: 1.6; +} + +/* Hide brand-gen decorative noise -- the wro.cpp aesthetic is calm + * and editorial, not a dark deck with glow + grid backgrounds. */ +.grid-bg, .glow { display: none !important; } + +/* ---------------- Card frame (1200x1200) ---------------- */ +.card { + position: relative; + width: 1200px; + height: 1200px; + background: var(--paper); + /* Faint warm radial wash, mirrors body { background-image } in + * src/styles/global.css:44-49 -- gives the paper texture without + * looking flat. */ + background-image: + radial-gradient(900px 700px at 80% -10%, rgba(234, 84, 30, 0.06), transparent 60%), + radial-gradient(800px 600px at -10% 110%, rgba(62, 181, 233, 0.05), transparent 60%); + overflow: hidden; + box-sizing: border-box; + padding: 130px 110px 130px 110px; + display: flex; + flex-direction: column; + /* Faint inner border gives the card a printed-page feel. */ + border-bottom: 6px solid var(--orange); +} + +/* Override: theme=dark cards still use paper. We keep the editorial + * light look across the board so the wro.cpp brand stays consistent. + * If the user really wants a dark variant later, this is the hook. */ +.card.dark { background: var(--paper) !important; color: var(--ink) !important; } +.card.dark h1, .card.dark h2, .card.dark p, +.card.dark blockquote { color: var(--ink) !important; } + +/* ---------------- INSIGHT card ---------------- */ +.card-insight { + justify-content: center; + padding-top: 200px; /* reserve space for logo watermark (top:90px + 64px + safety) */ +} +.card-insight .insight-content { + display: flex; + flex-direction: column; + gap: 60px; + max-width: 980px; +} +.card-insight h1 { + font-family: var(--font-display); + font-weight: 700; + font-size: 92pt; + line-height: 1.02; + letter-spacing: -0.025em; + color: var(--ink); + margin: 0; +} +.card-insight h1.title-long { + font-size: 72pt; + line-height: 1.06; + letter-spacing: -0.02em; + max-height: 420px; +} +.card-insight h1.title-xlong { + font-size: 56pt; + line-height: 1.10; + letter-spacing: -0.015em; + max-height: 440px; +} +/* Auto-accent: ++ in C++/C++26 turns orange, sentence-final period + * (when wrapped in ) turns blue. The skill writes + * the heading with these spans for the wro.cpp signature look. */ +.card-insight h1 .accent { color: var(--orange); } +.card-insight h1 .dot { color: var(--blue-deep); } +.card-insight p { + font-family: var(--font-body); + font-size: 30pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 0; + max-width: 920px; +} +.card-insight .insight-citation { + font-family: var(--font-mono); + font-size: 18pt; + letter-spacing: 0.04em; + color: var(--ink-faint); + margin-top: 40px; + padding-top: 30px; + border-top: 1px solid var(--rule); + text-transform: lowercase; +} +.card-insight .insight-citation::before { + content: '// '; + color: var(--orange); + font-weight: 700; +} + +/* ---------------- QUOTE card ---------------- */ +.card-quote { justify-content: center; padding: 140px 110px; } +.card-quote .quote-content { display: flex; flex-direction: column; align-items: flex-start; } +.card-quote .quote-mark { + font-family: var(--font-display); + font-weight: 700; + font-size: 200pt; + line-height: 0.8; + color: var(--orange); + opacity: 0.20; + /* In-flow above the text (not floated in the corner) with a negative + * bottom margin so the mark nearly touches the first quote line. */ + margin: 0 0 -0.62em; +} +.card-quote .quote-body { + font-family: var(--font-display); + font-weight: 600; + font-size: 64pt; + line-height: 1.15; + letter-spacing: -0.02em; + color: var(--ink); + max-width: 980px; + margin: 0; +} +.card-quote .quote-attribution { + margin-top: 50px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-muted); +} +.card-quote .quote-attribution::before { content: '-- '; color: var(--orange); } +/* author and role are adjacent spans with no separator in the markup; + * add one so they do not run together ("wro.cppC++26 ..."). */ +.card-quote .quote-attribution .role::before { content: ' / '; color: var(--ink-faint); } + +/* ---------------- STAT card ---------------- */ +.card-stat { justify-content: center; } +/* Value and label sit side by side (label wraps to stacked lines whose + * combined height roughly matches the value); context + source span the + * full width underneath. */ +.card-stat .stat-content { + display: grid; + grid-template-columns: auto 1fr; + grid-template-areas: + "value label" + "context context" + "source source"; + column-gap: 64px; + align-items: center; +} +.card-stat .stat-value { + grid-area: value; + font-family: var(--font-display); + font-weight: 700; + font-size: 240pt; + line-height: 0.82; + letter-spacing: -0.04em; + color: var(--orange); + margin: 0; +} +.card-stat .stat-label { + grid-area: label; + font-family: var(--font-display); + font-weight: 700; + font-size: 90pt; + line-height: 1.0; + letter-spacing: -0.02em; + color: var(--ink); + /* min-content forces a per-word wrap, so "codegen steps" stacks into + * two lines next to the value instead of running on one long line. */ + width: min-content; + margin: 0; +} +.card-stat .stat-context { + grid-area: context; + font-family: var(--font-body); + font-size: 26pt; + line-height: 1.45; + color: var(--ink-muted); + margin: 56px 0 0; + max-width: 880px; +} +.card-stat .stat-source { + grid-area: source; + margin-top: 44px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-faint); +} +.card-stat .stat-source::before { content: '// '; color: var(--orange); } + +/* ---------------- ANNOUNCEMENT card ---------------- */ +.card-announcement { justify-content: center; } +.card-announcement .announcement-meta { + font-family: var(--font-mono); + font-size: 20pt; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--orange); + margin-bottom: 30px; +} +.card-announcement .announcement-content h1, +.card-announcement .announcement-content h2 { + font-family: var(--font-display); + font-weight: 700; + font-size: 78pt; + line-height: 1.05; + letter-spacing: -0.02em; + color: var(--ink); + margin: 0; +} +.card-announcement .announcement-content p { + font-family: var(--font-body); + font-size: 28pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 40px 0 0; + max-width: 900px; +} + +/* ---------------- LOGO WATERMARK ---------------- */ +/* brand-gen hard-codes "ScudoAI" in .logo-wordmark; we hide it and + * draw "wro.cpp" via ::after on the watermark. The orange ".cpp" mirrors + * the brand-mark in the site header. */ +.logo-watermark { + position: absolute; + display: flex; + align-items: center; + gap: 18px; + height: 64px; + z-index: 10; + color: var(--ink); +} +.logo-watermark.top-left { top: 90px; left: 110px; } +.logo-watermark.top-right { top: 90px; right: 110px; } +.logo-watermark.bottom-left { bottom: 60px; left: 110px; } +.logo-watermark.bottom-right { bottom: 60px; right: 110px; } +.logo-watermark svg { + width: 64px; + height: 64px; + flex-shrink: 0; + /* Magnet logo PNG already has transparent paper-tone background; + * no rounded box needed -- it sits on the paper card directly. */ +} +.logo-wordmark { + font-size: 0 !important; + line-height: 0 !important; + /* Hide the upstream "ScudoAI" text node entirely. */ +} +.logo-watermark::after { + content: 'wro.cpp'; + font-family: var(--font-display); + font-weight: 700; + font-size: 28pt; + letter-spacing: -0.025em; + color: var(--ink); + line-height: 1; + /* The .cpp portion is given orange via a ::first-line trick below + * isn't reliable for inline -- so the SKILL writes the wordmark + * with explicit spans when it owns the markup. For this default + * rendering, the whole wordmark is ink and the orange comes through + * the bottom border + eyebrow. */ +} +.logo-watermark.top-right::after, +.logo-watermark.bottom-right::after { order: -1; margin-right: 18px; } + +/* ---------------- AI DISCLOSURE BADGE ---------------- */ +/* A small, honest "AI-GENERATED" label so the disclosure rides with the + * card image on social. Bottom-right corner (logo is top-left, citation is + * center-bottom, so this corner is free). Injected into index.html by + * inject.sh. See the /ai policy page. */ +.ai-badge { + position: absolute; + bottom: 74px; /* clears the 6px orange accent bar; sits in the bottom padding band */ + right: 110px; /* matches the card side padding / logo inset */ + z-index: 10; + font-family: var(--font-mono); + font-size: 14pt; + font-weight: 500; + letter-spacing: 0.10em; + text-transform: uppercase; + color: var(--ink-faint); +} + +/* ---------------- Defensive overrides ---------------- */ +/* Anything brand-gen might have set inline using its tokens. */ +* { box-sizing: border-box; } diff --git a/social/linkedin/return-std-move-const-copy/caption.md b/social/linkedin/return-std-move-const-copy/caption.md new file mode 100644 index 00000000..d6b5ebfb --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/caption.md @@ -0,0 +1,24 @@ +# Moving a const object returns a copy: 163 page faults per call on a 400 KB vector + +## Body +return std::move(book) on a const local is a copy. + +std::move on a const object yields a const T&&, and only the copy constructor accepts that. I measured it on GCC 16.2 with a 400 KB std::vector: the const case took 163 minor page faults per call (162.87 to 163.00), where a plain return and a moved non-const vector took 0 to 0.39. The time per call ran from 198 to 1354 microseconds on a shared machine, so I trust the fault count more. + +GCC 16.2 and Clang 22.1 warn on the const local with -Wall -Wextra, with the same text they print for a harmless move. Neither warns on a const member moved inside a const function, or on a const local used in an initialisation. clang-tidy performance-move-const-arg flagged both. The post lists seven shapes and which tool reports each. + +The faults depend on glibc's malloc thresholds: raising both mmap and trim thresholds with mallopt removed them. For a string in a struct, passing by value allocates from 16 characters on libstdc++ and costs none below that. A parameter the function stores is where by value plus std::move is right. + +This builds on an advert for a paid C++ trading course that Henrique Bucher posted. I have not seen the course or its measurements, so everything above comes from programs of my own. I did not test printf, unordered_map, Clang 18 or any trading workload. + +https://wrocpp.github.io/posts/return-std-move-const-copy/ + +## Hashtags +#cpp #cpp26 #movesemantics #copyelision #performance #clangtidy #wrocpp + +## Alt-text +wro.cpp card with the magnet logo. Headline reads "Move a const local and you copy 400 KB" with a subtitle about 163 page faults per call on GCC 16.2 and the shapes that clang-tidy flags. Citation footer: wro.cpp, 2026-12-28. + +## Suggested post time +Monday 2026-12-28, 08:00 UTC +Reason: the morning slot on the publication day, last of the seven daily posts from 22 December. diff --git a/social/linkedin/return-std-move-const-copy/config.yaml b/social/linkedin/return-std-move-const-copy/config.yaml new file mode 100644 index 00000000..e4148343 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/config.yaml @@ -0,0 +1,12 @@ +template: social/linkedin-post + +size: + width: 1200 + height: 1200 + dpr: 2 + +project: + name: "return-std-move-const-copy" + author: "Filip Sajdak, Founder & CEO" + email: "office@scudoai.com" + date: "2026-12-28" diff --git a/social/linkedin/return-std-move-const-copy/content.md b/social/linkedin/return-std-move-const-copy/content.md new file mode 100644 index 00000000..478931a1 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/content.md @@ -0,0 +1,12 @@ +--- +template: social/linkedin-post +--- + +::::post{type=insight theme=dark logo=top-left} + +:::insight{citation="wro.cpp -- 2026-12-28"} +# Move a const local and you copy 400 KB +On GCC 16.2 the const vector took 163 page faults per call, a plain return took none. Both compilers warn, with the text they give a harmless move. clang-tidy flags two shapes they miss. +::: + +:::: diff --git a/social/linkedin/return-std-move-const-copy/image.png b/social/linkedin/return-std-move-const-copy/image.png new file mode 100644 index 00000000..8f4a1a4f Binary files /dev/null and b/social/linkedin/return-std-move-const-copy/image.png differ diff --git a/social/linkedin/return-std-move-const-copy/index.html b/social/linkedin/return-std-move-const-copy/index.html new file mode 100644 index 00000000..535b6ed3 --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/index.html @@ -0,0 +1,28 @@ + + + + + + return-std-move-const-copy + + + + + + + + + + +

Move a const local and you copy 400 KB

On GCC 16.2 the const vector took 163 page faults per call, a plain return took none. Both compilers warn, with the text they give a harmless move. clang-tidy flags two shapes they miss.

wro.cpp -- 2026-12-28
ScudoAI
AI-generated
+ + \ No newline at end of file diff --git a/social/linkedin/return-std-move-const-copy/media/.gitkeep b/social/linkedin/return-std-move-const-copy/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/social/linkedin/return-std-move-const-copy/media/README.md b/social/linkedin/return-std-move-const-copy/media/README.md new file mode 100644 index 00000000..bb81c7fa --- /dev/null +++ b/social/linkedin/return-std-move-const-copy/media/README.md @@ -0,0 +1,9 @@ +# Media directory + +Drop images here (PNG, JPG, SVG) for use in your post. + +Reference them in your content.md with: + + :::image{src="screenshot.png" alt="Alt text" position="top"} + +The renderer resolves paths relative to this media/ directory. diff --git a/src/content/posts/2026-12-28-return-std-move-const-copy.mdx b/src/content/posts/2026-12-28-return-std-move-const-copy.mdx new file mode 100644 index 00000000..2506c53f --- /dev/null +++ b/src/content/posts/2026-12-28-return-std-move-const-copy.mdx @@ -0,0 +1,133 @@ +--- +title: "Moving a const object returns a copy: 163 page faults per call on a 400 KB vector" +slug: "return-std-move-const-copy" +pubDate: 2026-12-28 +author: filip-sajdak +language: en +kind: short +audience: working-cpp +tags: [cpp, move-semantics, copy-elision, performance, glibc, clang-tidy, gcc, clang] +summary: "On GCC 16.2, return std::move(book) of a const 400 KB vector copies it and takes 163 page faults per call, where a plain return takes none. GCC and Clang warn about it with the text they use for the harmless case, and miss two shapes that clang-tidy flags. A string passed by value costs one allocation from 16 characters." +draft: false +relatedPosts: [json-deserialize, pmr-zero-heap, pmr-benchmarks-2026] +--- + +import GodboltEmbed from '../../components/GodboltEmbed.astro'; +import PostLink from '../../components/PostLink.astro'; + +On GCC 16.2, `return std::move(book)` of a `const std::vector` with 400 KB copies the vector and takes 163 minor page faults per call. A plain return takes none. Both GCC 16.2 and Clang 22.1 warn about it, with the same text they print for a harmless `std::move`. Henrique Bucher{/* LINK: Henrique Bucher LinkedIn post, URL from the user */} posted an advert for a paid C++ trading course by Jordan Bucher. It lists costs of this kind. I have not seen the course, its code or its measurements. Every number below comes from programs of my own, run on Compiler Explorer on 2026-11-17. + +## In short + +- A `const` local returned with `std::move` is a copy. The cast yields a `const T&&`, and only the copy constructor accepts that. +- A 400 KB const vector returned that way took 163 page faults per call (162.87 to 163.00). A plain or moved non-const vector took 0 to 0.39. +- GCC 16.2 and Clang 22.1 warn on the const local with `-Wall -Wextra`. They say nothing about a const member moved in a const function. clang-tidy flagged both. +- A string in a struct, passed by value, costs one allocation from 16 characters on libstdc++. Up to 15 characters it costs none. +- A parameter that the function stores is the case where by value plus `std::move` wins: 1 allocation against 2 for a temporary. + +## Seven return shapes + +The advert, as I read it, gives 50 times for `return std::move(book);` on 400 KB. It gives 11 times for a struct that owns a string, passed by value instead of `const&`. Those are the course's numbers, and I do not judge them. The program below measures its own shapes: a `std::array` of 50,000 doubles, and `std::vector` of the same size. + +The faults are minor page faults from `getrusage`, divided by the 500 calls of a run. Times are the lowest and highest of seven runs, over three executions of the same binary on GCC 16.2. + +| shape | microseconds per call | faults per call | `-Wall -Wextra` on GCC 16.2 and Clang 22.1 | +|---|---|---|---| +| array, `return book` | 6.0 to 10.9 | 0 to 0.20 | silent | +| array, `return std::move(book)` | 20.7 to 38.7 | 0 to 0.20 | `-Wpessimizing-move` | +| vector, `return book` | 6.0 to 12.0 | 0 to 0.39 | silent | +| vector, `return std::move(book)` | 6.0 to 11.1 | 0 | `-Wpessimizing-move` | +| const vector, `return std::move(book)` | 198 to 1354 | 162.87 to 163.00 | `-Wpessimizing-move` | +| const vector of 100 KB, same | 3.9 to 6.7 | 0 to 0.03 | `-Wpessimizing-move` | +| 400 KB copied into a reused buffer | 8.6 to 11.9 | 0 | not a return | + +The array moves by copying 400 KB, so the moved return is a copy too. Comparing the fastest runs of each execution, it took about 3.4 to 4.2 times a plain return on GCC. On Clang 22.1 it took about 2.3 times. A vector moves three pointers, so the move costs nothing. + +The const vector is the expensive row, and its time swings from 198 to 1354 microseconds between runs. The fault count does not swing. I trust it more than the time. + + + +## Why the const case copies + +[Cppreference](https://en.cppreference.com/w/cpp/utility/move) defines `std::move` as a cast to `std::remove_reference_t&&`. For a const object that type is `const T&&`. A move constructor takes `T&&` and cannot bind to it, so overload resolution picks the copy constructor. + +The example proves this with a type that records which constructor made it, inside `static_assert`: + +```cpp +constexpr Probe make_const_moved() { const Probe local; return std::move(local); } + +static_assert(make_const_moved().made == Made::copied); +static_assert(std::is_same_v())), const Probe&&>); +static_assert(!std::is_constructible_v); +``` + +The last line shows the same cast on a move-only type: nothing can be constructed from the result. At run time `return local` was built in place and `return std::move(local)` ran the move constructor, on GCC 16.2 and Clang 22.1. The standard permits eliding a named local but does not require it ([cppreference](https://en.cppreference.com/w/cpp/language/copy_elision)). In constant evaluation GCC 16.2 ran the move constructor, so the file asserts only that the plain return is not a copy. + +## Where the page faults come from + +The `mallopt(3)` [manual page](https://man7.org/linux/man-pages/man3/mallopt.3.html) describes the mechanism. The mmap threshold starts at 128 KiB. When glibc frees a block above it, the threshold rises to that block's size. The trim threshold becomes twice the mmap threshold. Setting any of the parameters turns this adjustment off. + +I changed the settings with `mallopt` inside the program and counted faults per call. The file takes one of three words as its first argument: fixed, heap or keep. + +| row | default | `heap` | `fixed` | `keep` | +|---|---|---|---|---| +| vector 400 KB, plain or moved | 0 to 0.39 | 66 | 98 | 0 to 0.20 | +| const vector 400 KB, moved | 162.87 to 163.00 | 163 | 196 | 0 to 0.19 | +| const vector 100 KB, moved | 0 to 0.03 | 17 | 0 to 0.10 | 0 | + +`fixed` raises only the trim threshold, so the mmap threshold stays at 128 KiB. Every 400 KB block is then mapped fresh. That gives 98 faults, about 400,000 bytes divided by a 4 KiB page, and 196 for the const case with its two blocks. `heap` raises only the mmap threshold, so blocks stay on the heap and the trim threshold decides. `keep` raises both, and the faults vanish. + +Under the default settings my plain return takes no faults. A 400 KB block does not cross the mmap threshold on every call in this program. Two live blocks of that size do cost 163 faults, so memory goes back to the kernel between calls. I did not trace system calls, so I cannot say whether it leaves by unmapping or by trimming the heap. The runs show that raising both thresholds removes the faults, and that the 100 KB case has none by default. + +The copy itself is cheap once the memory stays mapped. With both thresholds raised, the const vector took 14.8 to 20.9 microseconds, against 6.0 to 8.8 for a plain return. These counts apply to glibc on Linux. Other allocators will differ. + +## Which tool reports it + +Seven functions in one file, built with `-Wall -Wextra` on GCC 16.2 and Clang 22.1, and checked with clang-tidy trunk on Compiler Explorer: + +| function | GCC 16.2 | Clang 22.1 | `performance-move-const-arg` | +|---|---|---|---| +| non-const local, `return std::move(book)` | `-Wpessimizing-move` | `-Wpessimizing-move` | silent | +| const local, `return std::move(book)` | `-Wpessimizing-move` | `-Wpessimizing-move` | fires | +| const local, `Levels out = std::move(book)` | silent | silent | fires | +| const by-value parameter, returned with `std::move` | `-Wredundant-move` | `-Wredundant-move` | fires | +| const reference parameter, returned with `std::move` | `-Wredundant-move` | silent | fires | +| member moved in a const member function | silent | silent | fires | +| member moved in a non-const member function | silent | silent | silent | + +The warning for the const local reads "moving a local object in a return statement prevents copy elision". It is the same text as for the vector that moves for free. The compilers do not say that the const case becomes a copy. The clang-tidy message does: "std::move of the const variable 'book' has no effect". + +Moving a non-const member out of a function is the correct use, and no tool flagged it. The JSON post does it with `return std::move(*r)` on a non-const local, where there is no local name to elide. + +Clang with `-Weverything` added only a C++20 compatibility note on the designated initialisers. GCC with `-Wpedantic -Wconversion -Wshadow -Wold-style-cast` added nothing. The check `performance-no-automatic-move` printed nothing for these shapes, and I did not look into why. + + + +## By value and const reference + +The second program passes a struct with a `std::string` and two doubles. A counting `operator new` gives the allocations per call: + +| symbol length | by value | `const&` | stored, by value | stored, `const&` | +|---|---|---|---|---| +| 4 | 0 | 0 | 0 | 0 | +| 15 | 0 | 0 | 0 | 0 | +| 16 | 1 | 0 | 1 | 2 | +| 28 | 1 | 0 | 1 | 2 | + +Fifteen characters is libstdc++'s small-string buffer, so the boundary is its own. Passing by value copies the string, which allocates only when the string does. Time per call over three executions: 4.3 to 8.4 nanoseconds by value against 2.6 to 4.1 for `const&` with 4 characters. With 28 characters, 12.3 to 17.0 against 2.6 to 3.6. Comparing the fastest runs of each execution, that is about 1.6 to 1.8 times for the short symbol. For the long one it is 4.7 to 5.2 times. The timing includes the counting `operator new`, and the struct is not the advert's, so the numbers do not compare with its 11 times. + +The last two columns pass a temporary to a function that stores it with `push_back`. By value moves the temporary into the vector, which costs one allocation, the one that built it. `const&` builds it and then copies it. For a parameter that the function keeps, by value plus `std::move` is the right shape. I ran only temporaries here, so I did not measure an lvalue argument to a stored parameter. + + + +For allocation counting with a replaced allocator, see the polymorphic allocator post. The benchmark post compares allocators and has a live allocation-count demo. + +## Not tested + +- The `printf` and `unordered_map` costs from the advert. +- Clang 18, which the advert's exercises use. I ran GCC 16.2 and Clang 22.1. +- Any trading workload, and any code from the course. +- Allocators other than glibc's, and page sizes other than 4 KiB. +- Whether the default-settings faults come from unmapping or from trimming the heap. + +The examples, with every observed output, are in the [examples repository](https://github.com/wrocpp/cpp26-reflection-examples/tree/main/posts/138-return-std-move-cost).