Description:
Discussion about C++ language, library, standards. (Moderated)
|
|
|
Virtual function call for an object under construction
|
| |
C++03 - 12.7/3: "When a virtual function is called directly or indirectly from a constructor (including from the mem-initializer for a data member) or from a destructor, and the object to which the call applies is the object under construction or destruction, the function called is the one defined in the constructor or destructor’s own class... more »
|
|
Semantics of some std::atomic<iType> member functions
|
| |
29.5.1 in N2960 declares the following member functions for std::atomic_itype: integral operator+=(integral) volatile; integral operator-=(integral) volatile; integral operator&=(integral) volatile; integral operator|=(integral) volatile; integral operator^=(integral) volatile; Some of these are also declared for std::atomic_address and std::atomic<T*>.... more »
|
|
Lambda captures in N2960
|
| |
Two things in N2960's lambda specification surprised me. First, captures by value of const/volatile objects seem to yield copies with the same cv qualifiers as the original. This means that if the original is const, the copy is const, too. That has the interesting implication that mutable lambdas can't modify the... more »
|
|
Contextual convertibility and logical operators
|
| |
Is the following correct, according to the upcoming standard? struct A { explicit operator int () {...} ...A a; bool b = a && true; ------------------- If it is not correct (I think it should not be correct, according to the rules of overloading resolution for operators), then it is not clear, why in 5.15.1 (as well as for other logical operators) the... more »
|
|
Question about new auto(x)
|
| |
Looking at N2960, 5.3.4 para 2 states that auto x = new auto('a'); will do type deduction based on T x = e; I'm assuming that means it would use the copy constructor to deduce the type, but does it use the copy constructor to actually initialize the variable, or will it then use the default constructor?... more »
|
|
Brace initializers and template type deduction
|
| |
What type do templates deduce for a brace initialization list? Consider: struct Widget { template<typename T> Widget(T); }; Widget w { 1, 2, 3 }; // compiles? if so, what is T? gcc 4.4 rejects the code, but it takes this version: struct Widget { template<typename T>... more »
|
|
How many parameters in T({x, y, z}) ?
|
| |
Consider the following attempt to construct a Widget object: Widget w( {5, 10, 15} ); How many arguments are being passed to the constructor? I say one, and gcc 4.4 seems to agree with me: ...class Widget { public: Widget(int, int, int) { std::cout << "3 ints\n"; } private: Widget(const Widget&) { std::cout << "copy\n"; }... more »
|
|
Refering to, naming and denoting variables
|
| |
Hello there. I find it difficult to get the difference of the above three terms. Below are some examples where i show my problems, i would be glad if you could comment on these. Thanks! 1) Variable What exactly is it? The Standard just says "A variable is introduced by the declaration of an object. The variable’s... more »
|
|
atoi, atof, and atol and c++ good
|
| |
I've have been told numerous times that it is not good practice to mix c and c++, and I see why: Standard c functions don't have exception handling or, for example, atoi doesn't have overflow checking. If I still happen to need a string to integer conversion while programming c ++, I feel that I'm in a dead-end. I shouldn't use atoi as it is c,... more »
|
|
diference betwen clear and swap trick
|
| |
Hello, i spent a bit time making tests to see wich of this two ways is fasters (in execution time i mean): We get an std::vector<T> v. Then we fill it. Then we want to delete it (erase form memory) 1. v.clear(); 2. std::vector<T>().swap( v ); And well, i made some test of quickness to ascertain wich way is the... more »
|
|
|