memesearch
C++ Template That Expires

C++ Template That Expires

Download Find similar pictures
Text on the meme
Playing around with requires clauses to create a C++ template that expires after a specific year. godbolt.org/z/9ocG1Mr9r template <int expirationYear> constexpr bool is_before_year() { const int currentYear = (__DATE__[7] - '0') * 1000 + (__DATE__[8] - '0') * 100 + (__DATE__[9] - '0') * 10 + (__DATE__[10] - '0'); return currentYear < expirationYear; } auto add(auto lhs, auto rhs) -> decltype(lhs + rhs) requires (is_before_year<2026>()) { return lhs + rhs; } int main() { return add(2, 3); }
What it means

A screenshot of a social media post shows C++ code defining an addition function that only compiles before the year 2026. The joke is that the template contains an artificial expiration date, making otherwise ordinary legacy code suddenly stop working after a specific year. EN: A screenshot of a social media post shows C++ code defining an addition function that only compiles before the year 2026. The joke is that the template contains an artificial expiration date, making otherwise ordinary legacy code suddenly stop working after a specific year.

Objects
Tags
Source
Type
image
Size
642×800 · 59.4 KiB
Mood
sarcastic
Language
en
Added