<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/medium-ojmvowxhc" -->

---
title: Medium | daily.dev
description: A deep-dive into C++ template metaprogramming using a tensor class as the motivating example. Starting from raw buffers and runtime classes, the post shows why...
canonical: https://daily.dev/posts/medium-ojmvowxhc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Medium | daily.dev
og:description: A deep-dive into C++ template metaprogramming using a tensor class as the motivating example. Starting from raw buffers and runtime classes, the post shows why...
og:url: https://daily.dev/posts/medium-ojmvowxhc
og:image: https://api.daily.dev/og/posts/OJMvoWXHc.png
og:image:alt: Medium
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Medium

**[Medium](https://daily.dev/sources/medium_js)** · 17 min read · 0 upvotes · 0 comments

## Summary

A deep-dive into C++ template metaprogramming using a tensor class as the motivating example. Starting from raw buffers and runtime classes, the post shows why runtime approaches fail to encode shape and element type in the type system. It then builds a compile-time tensor using non-type template parameter packs (`std::size_t... Dims`), fold expressions, `std::array` for inline storage, and C++23 multidimensional `operator[]`. The result is a type where a 2x3 and a 3x2 are genuinely distinct types, rank mismatches are compile errors, and the compiler can unroll offset arithmetic into straight-line code with no runtime overhead.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@abessiharoun/your-compiler-cant-tell-a-2x3-from-a-3x2-e2fd2d3e8c74>

## Similar posts on daily.dev

- [Compile Time Type Lists](https://daily.dev/posts/compile-time-type-lists-0c302enbz) · Jacek Galowicz · 0 upvotes · 0 comments
- [Tensor is the might](https://daily.dev/posts/tensor-is-the-might-v87pxfcye) · Hacker News · 0 upvotes · 0 comments
- [C\+\+26 Reflection gives us universal template parameters](https://daily.dev/posts/c-26-reflection-gives-us-universal-template-parameters-rzixrpk5v) · Arthur O'Dwyer · 2 upvotes · 0 comments
- [Who Owns the Memory? Part 3: How Big Is your Type?](https://daily.dev/posts/who-owns-the-memory-part-3-how-big-is-your-type--jjht5duxh) · Lobsters · 1 upvotes · 0 comments

---

Tags: [#c++](https://daily.dev/tags/c++)

[View this post on daily.dev](https://daily.dev/posts/medium-ojmvowxhc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Medium","url":"https://daily.dev/posts/medium-ojmvowxhc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/medium-ojmvowxhc"},"datePublished":"2026-07-27T19:46:17.864Z","dateModified":"2026-07-27T19:50:00.805Z","description":"A deep-dive into C++ template metaprogramming using a tensor class as the motivating example. Starting from raw buffers and runtime classes, the post shows why...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d6ab0a9a223ee01bc82d647f54feb2d2?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d6ab0a9a223ee01bc82d647f54feb2d2?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/medium-ojmvowxhc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c++","timeRequired":"PT17M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Medium"}]}
```

