Top "Const-correctness" questions

How to return a 'read-only' copy of a vector

I have a class which has a private attribute vector rectVec; class A { private: vector<Rect> rectVec; }; My …

c++ const-correctness
Unique pointer and const correctness

I was not expecting this code to compile: #include <iostream> #include <memory> class A { public: inline …

c++ pointers smart-pointers const-correctness object-composition
Does const-correctness give the compiler more room for optimization?

I know that it improves readability and makes the program less error-prone, but how much does it improve the performance? …

c++ c pointers constants const-correctness
Const function arguments in java?

Is there a way to achive something similar to C++'s const in Java? Specifically, I have a function like …

java const-correctness
about const member function

I met two explanation of const member function class A{ public: ... void f() const {} ... } it means it could only access …

c++ constants const-correctness
is it good practice to add const at end of member functions - where appropriate?

Is it a good practice, in C++, to add const at the end of a member function definition every time …

c++ constants const-correctness
Const correctness for value parameters

I know there are few question about const correctness where it is stated that the declaration of a function and …

c++ pass-by-value const-correctness
Why isn't it legal to convert "pointer to pointer to non-const" to a "pointer to pointer to const"

It is legal to convert a pointer-to-non-const to a pointer-to-const. Then why isn't it legal to convert a pointer to …

c++ pointers constants const-correctness