First  |  Prev |  Next  |  Last
Pages: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
calling this->~T() inside T::operator=
Consider this: T& T::operator=(const T& other) { if(this != &other) { // the below code destroys *this, right? // but are we not committing a suicide? - // destroying *this inside (*this).operator= ?? this->~T(); new (this) T(other); } return *this; } Thanks! -- [ See http://... 10 Dec 2009 08:58
pros and cons of returning const ref to string instead of string by value
Johannes Schaub (litb) wrote: Francis Glassborow wrote: Andrew wrote: When I write a method that returns a string I always return the string by value. This is as opposed to returning a const reference to the string held as a private data member in the object. Doing it my way means that wh... 9 Dec 2009 18:52
~ destructor doesn't destroy object?
#include <iostream> class My_class { public: void print() const { std::cout << "alive and well!\n"; } }; int main(int argc, char* argv[]) { My_class mc; // .. mc.~My_class(); // mc is destroyed above, right? how come it come be used? mc.print(); return 0; } Or, is the... 13 Dec 2009 04:34
Templates conditional type
Hi, can I define type of a variable based on some other type using templates? For example I have template <typename T> struct A { type x; }; and I want to define member variable x of A, such that if T is char, then x will be of type int, if T is float, then x will be of type double etc. Is this possible via... 10 Dec 2009 10:04
Multiple inheritance
I have hierarchy, that contains one base interface class - IConnection, and two derived interfaces: IClientConnection and IServerConnection ================= class IConnection { public: virtual void Send() = 0; }; class IClientConnection : public virtual IConnection { public: virtual void Conn... 17 Dec 2009 09:15
Variadic Templates – Recursion – Initializer Lists.
Seems to me like the only way to write functions/classes taking variadic templates is by recursion. Is that true? Can the below work, for iteration? template<class� T> auto func(const T&� t){ std::initializer_list<?> ilist = {t�}; //what should go here <?>// for(const auto& arg : ilist) //use arg// } ... 9 Dec 2009 18:52
Sequence Point
Hi, 5.17/1 mentions "In all cases, the assignment is sequenced after the value computation of the right and left operands, and before the value computation of the assignment expression." This statement is not clear to me. Consider the code below: int a = 0, b = 0, c = 0; a = b + c; The steps in the evalu... 13 Dec 2009 04:34
Fast Assignment of POD Struct Whose Members Have Copy Constructors
On Dec 8, 6:40 pm, George Neuner <gneun...(a)comcast.net> wrote: On Mon, 7 Dec 2009 13:51:13 CST, Le Chaud Lapin IMO, always calling the function is a cop out ... generating correct inline code really isn't that hard and you can always limit the inlined cases to those that are aligned and simple to count and ... 9 Dec 2009 16:38
concurrent linked queue class for C++?
I am designing a system where an app will need to spawn a child thread then the child and parent thread will need to communicate. If this was in java I would use ConcurrentLinkedQueue but what to do in C++? I have googled and searched boost but cannot find anything. There is a class that would serve in ACE but AC... 31 Dec 2009 17:37
Dependent function templates and overloaded functions
Hi, consider this code: #include <iostream> template<typename T> inline int match(const T &x) { return 23; } template <typename T> inline int not_match(const T &x) { return match(x) + 1; } template <> inline int match<int>(const int &x) { return 42; } inline int match(const double &d... 11 Dec 2009 18:02
First  |  Prev |  Next  |  Last
Pages: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60