This is not okay.const int* const foo(const int* const x) const;
Who in their right mind decided using a keyword for this many purposes was an acceptable thing to do?
>>62435102
This only shows 2 meanings of `const`---the const after the function which means the function doesn't modify the object it's a member function of, then the `const` in the type names just means the same thing but is attached to different parts of the type (const pointer to const int)
But really you shouldn't make the values themselves const in C++ and nobody ever does that. You normally just make the thing that's referenced / pointed to const, so instead you should doconst int *foo(const int *x) const;
which means "(non-const) pointer to const int"
>>62435102
>(const int* const x
Why the fuck would you do that? passing an int is just as same as passing a pointer
>>62435238
It was an intentionally retarded example
I understand C++ is all about letting you shoot yourself in the foot, but reusing const for more than one purpose seems cluttered to me
>>62435287
>but reusing const for more than one purpose seems cluttered to me
It really doesn't though. It means exactly one thing all the time. Of course, each level of indirection adds one level of potential const-ness, so an int**** could have five "const" qualifier and an int**************** could have seventeen, but that doesn't mean that const has seventeen different meanings.
>>62435401
>const, though used in different contexts, still makes a thing immutable
That make much more sense than the way I was thinking about it. Thanks for giving this brainlet another wrinkle.
>>62435102
Holy Jesus put `const` after what it refers to, this isn't Javascript.