How to reduce the capacity of a std::vector

With C++11, you can call the member function shrink_to_fit(). The draft standard section 23.2.6.2 says: shrink_to_fit is a non-binding request to reduce capacity() to size(). [Note: The request is non-binding to allow latitude for implementation-specific optimizations. —end note]

Assignment operator inheritance

Actually, what is called is the implicitly defined operator = for Derived. The definition provided by the compiler in turn calls operator = for the Base and you see the corresponding output. The same is with the constructor and destructor. When you leave it to the compiler to define operator =, it defines it as … Read more

C++ const in getter [duplicate]

There is a huge difference between the two ways. const bool isReady() The code above will return a const bool, but it does not guarantee that the object will not change its logic state. bool isReady() const This will return a bool, and it guarantees that the logic state of your object will not change. … Read more

What are some tricks I can use with macros? [closed]

In C, it’s common to define macros that do some stuff getting the verbatim argument, and at the same time define functions to be able to get the address of it transparently. // could evaluate at compile time if __builtin_sin gets // special treatment by the compiler #define sin(x) __builtin_sin(x) // parentheses avoid substitution by … Read more

techhipbettruvabetnorabahisbahis forumueduseduseduseduseduedueduedusedusedus