I am writing a C++ program for Linux. I use many low-level libraries such as XLib, FontConfig, Xft etc. They are all written in pure C, and in some pl ...
I am writing a C++ program for Linux. I use many low-level libraries such as XLib, FontConfig, Xft etc. They are all written in pure C, and in some pl ...
In a class header file Texture.h I declare a static const int. In Texture.cpp I define the variable as 0. Now in Window.cpp class's constructo ...
Is it possible to remove constness of vector ? If so, how can it be achieved? For some reason, I don't have access to the main (), can I still remove ...
I have a doubt about about a line of the code wrote from my professor. This is the full code. The relevant function is The class Gui has a std::l ...
Same question as Create a streambuf from const char* except that I can't use boost. I have to implement an function that takes a const char * as inpu ...
Among static_cast, dynamic_cast, reinterpret_cast and const_cast, only static_cast is able to return an object of desirable type, whereas the other ty ...
int main(){ const_cast<int&&>(0); } According to expr.const.cast#4 For two object types T1 and T2, if a pointer to T1 can be exp ...
I've made a simple Huffman encoding program to output individual encodings for characters and save the encoded file. This was for an assignment, and I ...
Quick question for the folks out there. I have the function signature below that under some but not all circumstances returns a const type qualifier o ...
I came across some code which has several instances of the bellow example: In this simplified example there is an assignment of std::string::c_str( ...
I've read quite a few discussions that const_cast in C++ is considered wrong and dangerous and should not be used for anything other than backward com ...
I have a C++ 11 header which has a const value declared as my_const_value. And a function called GetValue that runs a complex logic using the const va ...
From [expr.const.cast]/3: For two similar types T1 and T2, a prvalue of type T1 may be explicitly converted to the type T2 using a const_cast if, ...
Error: Invalid conversion from 'char**' to 'const char**' Similar questions did not appear to have the same set of circumstances (i.e. two functions ...
Why can a non-static const member be assigned using const_cast, and when would this be useful? In the following code, both A and B classes compile a ...
There are a couple of questions with similar names on StackOverflow, such as this one and this one .etc However, none of them answered the questions ...
This is something that came up recently and which I feel shouldn't work as it apparently does: The use of shared_ptr isn't necessary here, but the ...
Basicly I have volatile const char* and want to create a string. The volatile keyword here is in all likelyhood irrelevant(a misunderstanding from a p ...
When compiling the code below, I am getting an error on line 3 about the result of const_cast not being an lvalue. Is this only a problem because I us ...
I am looking to do something like this (C#). The potential solutions and their associated problems I've encountered are: 1. Using const for the cl ...