C++ is a monstrosity

class X {
mutable const int* p; // OK
mutable int* const q; // ill-formed
};


How does this make any sense? What does it even mean to have a mutable but constant integer? Why is it illegal to have an immutable pointer to a mutable integer?

Attached: ty2Pmn.jpg (951x840, 90K)

You obviously copied this example from cppreference. Read that article instead of asking here.

p is a mutable pointer to a constant integer
q tries to declare an immutable mutable pointer to a mutable integer

The thing that's mutable is the pointer, not the thing it points to.

nobody uses these keywords

c++ retards do

no one uses mutable. the only* and literally only sane case for mutable is for optimizing via caching a value in something that's threaded. any other use and you're a fucking idiot.

i thought that was volatile

mutable - permits modification of the class member declared mutable even if the containing object is declared const.

volatile has to do with hardware managed memory
iirc it tells the compiler not to optimize things away

no he is proving his point. that C++ is to complex for most users and you had to lockup what even simple self explaining keyword does.

Look up the spiral rule

Most users can go fuck themselves.
If you're too much of a brainlet to understand a language so complicated they created a second programming language inside of it, by accident, you should not be programming.

>volatile has to do with hardware managed memory
cache. volatile vars will not be cached thread-locally, only in shared caches. it's for avoiding stale reads in concurrent scenarios.

I was refering to how mutable works, in that it ignores const allowing you to.. mutate the structure the only sane time that's ever valid is if you are mutex'ing data access and trying to cache data/calculations in something multithreaded. every other case is a mistake (and I'd argue even that case is a mistake).

You can't be both const and mutable at the same time, it's antinomic, so your second example does not work.

But it's fine to change a pointer to a const object.

ITT: people who wrote less than 100,000 lines of C++

how do you know whether the const refers to the pointer or the data it refers to?

Pretty much every language requires the words be put in a particular order. Why pick on C++ for this?

the projects i've done with vulkan are probably more than 100,000 lines on their own

For the love of god, why?

C/C++ is old now we have const and mutable which is stupid, one of those should be default so u specify only the non default case in C/C++ mutable is default while in Rust/D const ist default.
class member function declared with const could since ever modify a const class. so i think a const instance of class should be threadsave as long as i only call const member functions. maybe the tough they want the same for member variables.

how can you have a variable that is mutable and const? think for one moment

>I don't know what mutable means

>I don't know what mutable means

Mutable is not the "opposite" of const you humongous fucking retard.
const: can't be modified
mutable: can be modified, even if the class is const
non-const: only modifiable if the class is non-const

>and I'd argue even that case is a mistake
Autism. Modifying the cache of a const object doesn't violate its logical state.

that's c++'s convention, not the definition

This, mutable is essential for any kind of lazy object.

>For the love of god, why?
It helps with the pattern of having 'const' everywhere it's possible, while still implementing things like caches/memoization, support code, etc.

It means the responsibility is on the develop to make sure the class can still be used as if it was purely const.

For example you could have use a const-qualified object that has a mutable thread-safe logger.

It also helps with software maintenance. If you have a mostly-const-compatible class with one annoying member, you could explicitly mark that one as being mutable.

see what you need is a default const language, which is increasingly popular nowadays

Const by default doesn't play nicely with environments that lack a GC.

hAvE yOU hEarD aBOuT rUsT?

Attached: 1530464849192.png (669x696, 481K)

>C++ is a monstruosity

Yeah, you're right, what about it? Even the biggest fanboys will tell you the same: it's fast and do the job, but is horribly bloated and loaded with non-sensical stuff

Have your heard about Ada? Faster, more reliable and neat as fuck

Yeah, the restrictions on mutability are one of the worst things about it

>faster
no
>reliable
yeah it's been around for a lot longer for sure. they are taking the ownership model from rust though so they do seem to like some of its ideas
yeah learning how not to run into the BC is definitely the learning curve

actual constructive replies on Jow Forums to a post with the word rust in it, incredible

Erlang is an old, 10/10 language and const by default.

Ada is indeed faster, zoomer.
Also, the ownership model has been around since decades, rush didnt invent it

>wuts durr diffrunz between read-only pointurr and cernstnt pointurr?

Attached: brainlet black hole.jpg (700x700, 209K)

>dont even use c++ but understand how to read the types
>it makes perfect sense
Your a brainlet op, sorry

yes it being a functional language of course it'll be const default. 10/10 though is never happening with dynamic typing, see haskell for that
alright if it's faster than "rush" go prove it, since on good benchmarks "rush" is on par with C

Brainlet OP can't even into C++ lmao

struct List;

using String = std::string;

struct Identifier {
std::string str;

Identifier(std::string str) : str{str} {}
};

using Number = variant;

using Boolean = bool;

using Datum = variant;

struct List {
vector datum;
};

struct ExpressionApp {
shared_ptr id;
vector datum;
};

using ExpressionQuote = vector;

using Expression = variant;

using ParameterName = shared_ptr;

using Body = vector;

struct DefinitionVar {
shared_ptr id;
shared_ptr datum;
};

struct DefinitionFun {
shared_ptr id;
vector param_names;
shared_ptr body;
};

using Definition = variant;

using Form = variant;

using Program = vector;

>C/C++ is old now we have const and mutable which is stupid, one of those should be default so u specify only the non default case in C/C++ mutable is default while in Rust/D const ist default.
Non-const is the default. This hasn't changed.

>Ada
>Faster than Rust
You are taking your meme way too far, faggot.

Attached: Screenshot from 2019-08-09 23-42-26.png (1828x974, 185K)