error: passing const xxx as ‘this’ argument of member function discards qualifiers

The objects in the std::set are stored as const StudentT. So when you try to call getId() with the const object the compiler detects a problem, mainly you’re calling a non-const member function on const object which is not allowed because non-const member functions make NO PROMISE not to modify the object; so the compiler … Read more

Why use std::less as the default functor to compare keys in std::map and std::set?

I decided to ask Alexander Stepanov (designer of the STL) about this. I’m allowed to quote him as follows: Originally, I proposed 3-way comparisons. The standard committee asked me to change to standard comparison operators. I did what I was told. I have been advocating adding 3-way components to the standard for over 20 years. … Read more

Is there a difference between using .begin() vs .end() for std::inserter for std::set?

In practice, not much. If you’re inserting a large number of already in order elements into an empty set, the second will be somewhat faster, but that’s about it. std::insert_iterator calls insert with the iterator; std::set interprets it as a hint, and inserts in constant time (rather than lg n) if the insertion is immediately … Read more

Is the C++ std::set thread-safe?

STL has no built in thread support, so you’ll have to extend the STL code with your own synchronization mechanisms to use STL in a multithreaded environment. For example look here: link text Since set is a container class MSDN has following to say about the thread safety of the containers. A single object is … Read more

c++ STL set difference

Yes there is, it is in <algorithm> and is called: std::set_difference. The usage is: #include <algorithm> #include <set> #include <iterator> // … std::set<int> s1, s2; // Fill in s1 and s2 with values std::set<int> result; std::set_difference(s1.begin(), s1.end(), s2.begin(), s2.end(), std::inserter(result, result.end())); In the end, the set result will contain the s1-s2.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)