Description:
Technical discussion of the C++ language. (Moderated)
|
|
|
Streaming a wstring to a wofstream
|
| |
Is there ever any case in which streaming a wstring to a wofstream should fail to write all the characters in the wstring to the file ? In code, built with VC9 in Windows, I have: std::wstring astring; // Code that fills the wstring with about 210,000 wide characters. // I can verify the size of this in the debugger.... more »
|
|
Another Koenig lookup thread, yes, kill me now
|
| |
Now, I don't want to start a flame thread, and I apologize for bringing this up. However, I do have a couple things I would like clarified. To start, here's one of the well known problems with Koenig lookup. // **** main problem namespace A { class foo {}; template <typename T> void helper (T) {}... more »
|
|
Detection of fatal errors
|
| |
Hi, Is there any way to perform an action before program's exit, when it encounter some kind of fatal error? Namely I'd like to detect a fatal error and dump buffer with logs to a file in situations like below: ---- example 1 ---- int *a = 0; *a = 21; ---- example 1 ---- MyClass *a; a->someFunction();... more »
|
|
a different way to get the stringifyed value of an enumeration
|
| |
I have been thinking about how to use enums such that it is easy to get at stringifyed value of an enumeration. Over the years I have come up with various solutions which all involve use of the macro preprocessor to generate lookup code that matches the enumeration to the string, using stringification mechanisms available to... more »
|
|
LWG Issue #387 -- std::complex
|
| |
preamble: The C++ Library Working Group is currently revising the definition of std::complex. As time has progressed, Issue #387 has fixed some problems and reintroduced others. Hopefully this post will generate the discussion needed to obtain a widely-usable API. Thanks, Daniel Herring dnunt...@gmail.com... more »
|
|
Exception safety -- once again
|
| |
Hi, As far as I understand exception safety forbids to do anything within a exceptions constructor which might itself throw an exception. But is it o.k to do such things when preparing an exception to be thrown ? like: <snip> foo() thow(std::exception) { int c; if((c=bar())!=0) { std::stringstream ss;... more »
|
|
overriding new and delete operators...and didn't work as I expected
|
| |
I have code like bellow... class AncestorClass { public: AncestorClass() {} virtual ~AncestorClass() {} static void* operator new(size_t _size) { cout << "AncestorClass new" << endl; AncestorClass* _ptr = ::new AncestorClass(); if (_ptr) _ptr->Initialize(); return _ptr; } static void operator delete(void* _ptr)... more »
|
|
Singletons and destructors
|
| |
Hi all. I have struggled for a couple of days with a singleton pattern. It turned out that the cause of the problem is that the destructor of a singleton pattern is not called unless somebody calls a 'delete' to a pointer to the singleton. Below is an example, where the program reports what methods it calls. The only way I can find to see a report from the... more »
|
|
Array of unknown bound
|
| |
Hi, $8.3.5 para 6 says "-6- If the type of a parameter includes a type of the form ``pointer to array of unknown bound of T'' or ``reference to array of unknown bound of T,'' the program is ill-formed.* [Footnote: This excludes parameters of type ``ptr-arr-seq T2'' where T2 is ``pointer to array of unknown bound of T'' and where ptr-arr-seq... more »
|
|
"Function Types"
   
|
| |
Hi, $4.3 talks about conversion of functions to pointers, specifically "An lvalue of function type T...". My idea of "function type" is based on the following article from Herb "[link]". I wrote the following small piece of code. // CODE SNIPPET 1 int *fn(int *p, const char& rc){return (int *)0;}... more »
|
|
|