Recently I've noticed that the following statement is not true given std::string s.
s.max_size() == s.get_allocator().max_size();
I find this interesting, by default std::string will use std::allocator<char> which has a theoretical limit of size_type(-1) (yes i know I'm assuming 2's complement, but that's unrelated to the actual quest...
On Linux, malloc doesn't necessarily return a null pointer if you're out of memory. You might get back a pointer and then have the OOM killer start eating processes if you're really out of memory. Is the same true for c++'s operator new or will you get the bad_alloc exception?
...
I have noticed that when I was running Windows XP, if my code dereferenced null I would get a crash in debug and I could then easily identify where the bug was coming from. It seems that in Windows 7 (I'm running 64-bit), instead of crashing or creating any sort of notification, the code will simply break its current iteration and start...
I'm using sockets in c++ on linux to connect to a server using connect(), but it doesn't seem to have a timeout value. What would be the easiest/best way to give it a timeout of a few seconds. I'll post the code I have up to, and including, the blocking call to connect():
using namespace std;
int main( int argc, char* argv[] )
{
...
Heap fragmentation can cause a server application that is expected to run continuously for many months to suddenly start malfunctioning thinking that it's out of memory.
Let's assume that I've done my best to minimize runtime heap fragmentation in my VC++ server application but still it builds up and causes problems. I could for example...
I need a simple UUID generator.
The ID is required to be unique for this single instance.
Another requirement is, that it has n hashes coexisting at a time, and being releasable.
I don't know wether this fits the UUID concept or not.
I allrdy thought about a Stack with n-values using pop and push, but this practice seems bad memory wise....
Hello, how can I send command to a Windows service from C++? Equivalent .NET code is:
ServiceController sc = new ServiceController("MyService");
sc.ExecuteCommand(255);
...
Hi.
I want to include the libavcodec in my Qt-project.
Should I do that with
#include <ffmpeg/libavcodec.h>
or with something more Qt, for example
QLibrary mylib("libavcodec");
And also a question to understand if I really got it: To use libavcodec, do I need to import the source-files or the .dll?
...
We do have a project wich uses the MIDL tool to create specific header/iid and proxy files. Those files are compiled and linked with the rest of the project using a post build step that calls nmake.
Is it possible to use precompiled headers with thos IDL generated files? How can I inject #include "stdafx-h" and remove other included hea...
Let's say I have this C++ code:
void exampleFunction () { // #1
cout << "The function I want to call." << endl;
}
class ExampleParent { // I have no control over this class
public:
void exampleFunction () { // #2
cout << "The function I do NOT want to call." << endl;
}
// other stuff
};
class ExampleChild : pub...
I have been through every option to try to find a way to get the IDE to let me create a new win32pject without precompiled headers. I have read every thread on this forum with the words "precpmpiled headers" in it and the closest I got was:
http://stackoverflow.com/questions/1293538/precompiled-headers
Using 2008 pro (not express, alth...
hello, how can i get the memory address of the value a pointer points to? in my case it is a void pointer.
just assigning it to an uint gives me this error:
Error 1 error C2440: 'return' : cannot convert from 'void *' to 'UInt32'
thanks!
...
Hi
I am having trouble in CE BltBit from a previously created compatable hdc to device's hdc.
The following code works:
hdc = pdis->hDC;
FillRect(hdc, &(pdis->rcItem), (HBRUSH)GetStockObject(BLACK_BRUSH));
ImageList_Draw(himl, imageIndex, hdc, 15 , 30, ILD_NORMAL);
However the following just draws the black rectangle and does n...
I guess I am a bit puzzled by the syntax. What does the following mean?
typedef char *PChar;
hopeItWorks = PChar( 0x00ff0000 );
...
How do I write a program to overload the + operator so that it can add two matrices?
...
I am using c++, libjpeg for decoding jpeg file.
I find it is not fast enough, is there any method to make it faster by setting some compile parameter?
or are there any other lib can open jpeg files more faster?
now it takes about 750ms to open a 4368 * 2912 4m jpeg image.
I wish this can be reduced to 150ms.
Many thanks!
Added:
IJL see...
While I was working i came across a code which was written by somebody else.
i see a statement as ,
sprintf(o_params->o_file_name,
"%s_%s_%04.4d_%s_%s.ASC",
"OUTD", "RM", sequence_no, DateStamp_buf1, TimeStamp_buf1
);
In the above statement, I see %04.4d. Is this a correct format specifier?
The variable sequence_no ...
Why do we need two? Under which circumstance each of the following operator[]s are called?
class X {
public:
//...
int &operator [](int index);
const int &operator [](int index) const;
};
...
What is the difference between the index overloaded operator and the insert method call for std::map?
ie:
some_map["x"] = 500;
vs.
some_map.insert(pair<std::string, int>("x", 500));
...
Hi,
I want to be able to stop a user from moving a QSplitter at runtime. Calling setEnabled(false) does this, but it also disables all child widgets - which isn't what I want. Is there a way to achieve this? Do I have to disable the splitter, and then manually re-enable all child widgets? That seems rather cumbersome, for something that...