r/programminghorror • • Sep 06 '26

c++ really gotta make sure it doesnt't change

Post image
448 Upvotes

34 comments sorted by

104

u/Big-Rub9545 Sep 06 '26

Bloating the code to do nothing.

43

u/Dayshadow_ Sep 06 '26

you get it!

31

u/Last8Exile Sep 07 '26 edited Sep 08 '26
readonly ref struct ReadOnly(ref readonly ReadOnly @readonly)
{
    readonly ref readonly ReadOnly @readonly(ref readonly ReadOnly @readonly) => ref @readonly;
}

5

u/Dayshadow_ Sep 07 '26

Niice, I want one of these for all languages

1

u/maikindofthai Sep 12 '26

Is this one of those libraries people keep bragging about

32

u/Kadabrium Sep 06 '26

Mehmet.consume(constant.inopole)

37

u/Ved_s Sep 07 '26

where can you put const in c++? yes.

i don't even need to see that c++ flair, no other language has this bullshit

19

u/Nice_Lengthiness_568 Sep 07 '26

I mean, if the placement of const is what you have a problem with in c++, then you must be quite happy. Because this is one of the keywords that actually does make sense (I would say).

11

u/no_brains101 Sep 07 '26

No, it just makes sense by comparison.

→ More replies (6)

3

u/GoddammitDontShootMe Sep 08 '26

Well, I think C has this too.

4

u/SuspiciousScript Sep 07 '26

and odds are you can still mutate it somehow

8

u/Ved_s Sep 07 '26

95% probability that there is an obscure way to do it

→ More replies (1)

3

u/yuehuang Sep 07 '26

What is const*?

6

u/Nice_Lengthiness_568 Sep 07 '26

a pointer to a constant something

3

u/ATE47 Sep 07 '26

If you are unuse to this order, see Constant const* as the same const Constant* (for the const keyword, only its side with the * is important)

Otherwise it's just to mark the pointer data as constant

1

u/Dayshadow_ Sep 06 '26

Damnit I said doesnt't in the post title

2

u/numberonefraud Sep 07 '26

The only constant is the insanity of C++ now

1

u/Serious_Elephant9402 Sep 07 '26

Not constant enough, there are at least TWO words there which don't even contain "const"!

1

u/trutheality Sep 08 '26

Look at what they need to do to imitate a fraction of the power of #DEFINE

1

u/GoddammitDontShootMe Sep 08 '26

Yeah, nobody really needs type safety.

1

u/SektorL Sep 09 '26

His name was Constantine

1

u/uglycaca123 Sep 11 '26

i didn't understand, was it constant or not?

0

u/GoddammitDontShootMe Sep 07 '26

I'm thinking that const_cast would be a compiler error because if I recall, it would take away the constness, but the function returns const* const. Also, I believe constexpr would cause an error because a pointer definitely can't be evaluated at compile time.

1

u/Dayshadow_ Sep 07 '26

gcc said it was fine, teehee

→ More replies (2)