Description:
Technical discussion of the C++ language. (Moderated)
|
|
|
Can a constexpr function throw an exception?!
|
| |
I see that in N2798, the bitset::test function is now constexpr bool test(size_t pos) const; but is still required to throw an out_of_range exception for an invalid pos parameter. ...constexpr function to be { return expression; } where the expression is supposed to be a "potential constant expression (5.19)". However 5.19 specifically lists a throw expression... more »
|
|
stringstream misunderstanding
|
| |
Why won't this work? stringstream ss; ss.str() = "have a nice day."; cout << ss.str() << endl; I know that ss << "have a nice day."; works, but I thought the str() function would permit me to read to write to the ss buffer. Thanks, Joe
|
|
Why the decision to leave typeinfo::name() out of the standard?
|
| |
Hi, Basically, this little string right here, could be extremely helpful if it was portable. Couldn't the standard committee just come up with a simple scheme for this? namespace::classname? I'm writing a serialization lib and it's damn hard to make it portable without it. Does anyone know why it never got to be in the standard?... more »
|
|
explicit conversion from unique_ptr<T> to shared_ptr<T>
   
|
| |
DR #674 declares the construction of a shared_ptr<T> from a unique_ptr<T> && as being explicit, possibly to mimic the behavior of the construction from an auto_ptr<T> in C++03 days. Is there a real need for it to be declared explicit, now that we have rvalue references? Since only construction from rvalue references are accepted (opposed... more »
|
|
operator++(int);
   
|
| |
Hi, I'll start with a quote from D&E, page 246. It's about how to distinguish ++i from i++ when overloading operator++ for decltype(i). "Several alternatives that did not involve new keywords were suggested. For example: class Ptr_to_X { // ... X ++operator(); //prefix ++ X& operator++(); //postfix ++... more »
|
|
destruction of std::map, heap corruption
|
| |
{ Note that questions are better answered when posted with a minimal, compilable standard C++ code by relevant definitions supplied and irrelevant dependency upon proprietary features removed. Responders are encouraged to stay within the standard C++. -mod } Hello, msvc2005 (main.cpp and another .cpp in a DLL)... more »
|
|
catch match
|
| |
What should this code output ? ...class my_exception : std::exception { public: static void foo() { try { throw my_exception(); } catch(const std::exception&) { std::cout << 1 << std::endl; } catch(const my_exception&) { std::cout << 2 << std::endl;... more »
|
|
Iteration over the structure fields
|
| |
Is there any quick and neat way to perform some repeated operation over all the fields of a structure without repeating the same code for each individual field? E.g., instead of writing this struct some_struct {float field1; int field2; double field3; /*many other fields*/}; some_struct a_struct; f (a_struct.field1);... more »
|
|
Conversions in template functions
|
| |
While learning function templates I wrote below program to understand better. The compiler output is also given below. The doubt that I've here is that why is the compiler doing conversion of double(1.1980) to int when it can convert int to double (to "wider one") and could use template generated function(my_max<double>(double ,double)) rather than handwritten... more »
|
|
|