Linked Questions
39 questions linked to/from Does C++11 allow vector<const T>?
2 votes
2 answers
311 views
Why I can't use a reference type inside a `std::initializer_list`
when I try to use an initializer list for a member that contains references, I get the following error: no matching function for call to ‘std::vector<const Exp&>::vector(<brace-enclosed ...
0 votes
3 answers
707 views
"pure virtual function call" error on Debug ONLY
The following "Event" code snippet shows the "pure virtual function call" error. However, as mentioned in the title, it happens only when deploying on DEBUG. What makes me curious is why it works ...
2 votes
2 answers
246 views
Why can't a std::vector hold constant objects?
I am not sure why the following code is not allowed to exist: int main() { std::vector<const int> v; v.reserve(2); v.emplace_back(100); v.emplace_back(200); } In theory, reserve(...
0 votes
1 answer
169 views
Replace boost::bind with lambda
I would like to replace a boost::bind with a lambda. Can you please advise on how to go about doing this? I have a function declared as bool myFunction(const vector<double>& input, vector<...
0 votes
3 answers
117 views
Understanding const pointers to const value in C++
I have two questions. First of all I have a little problem with the understanding of const pointers to const values. I don't get why B::insert works, while C::insert results in a compiler error. I ...
0 votes
0 answers
252 views
How to insert values to vector of const pointers
I am aware of the following post: Does C++11 allow vector<const T>? however I am not able to solve my problem. I am trying to define a vector with a list of const shared_ptr of my class "...
0 votes
1 answer
132 views
Convert std::vector<std::pair<const K, V>*> to std::vector<std::pair<const K, V>>
I want to convert std::vector<std::pair<const K, V>*> to std::vector<std::pair<const K, V>>. However, as you know due to pair<const K, V> I can't assign. I guess there ...
0 votes
0 answers
115 views
Is std::vector<const int> undefined behaviour?
After reading this post I tried this #include <iostream> #include <vector> int main() { const int x = 5; // x = 200; Not possible, of course. std::vector<const ...
0 votes
0 answers
82 views
Casting std::vector<T*> into std::vector<const T*> [duplicate]
I have this code: class A {}; // Can't modify the signature void DoSomething(std::vector<const T*>& outArray) { // do something here and fill outArray } void main(void) { std::...