I have a class that accepts a list of policy classes using boost::mpl. Each policy class contains an identifying tag. I would like MyClass to produce the OR-ed result of each policy class' identifying tag. Unfortunately, I'm having some trouble figuring out how to correctly use the boost::mpl::fold<> functionality. If anybody can help, I...
Hello,
I'm trying to find concrete examples of how to manage breaking an incoming stream of data on a TCP/IP socket and aggregating this data in a buffer of some sort so that I could find the messages in it (variable length with header + delimiters) and extract them to reconstruct the messages for the receiving application.
Any good po...
So I have 2 classes, Bullet and Ship, that are dependent on each other, hence circular inclusion. Since I have Ship's interface #included into Bullet's interface, the obvious decision was to forward declare Bullet to Ship.
However, when I first tried this I still got compiler errors. I read up a bit on forward declaration and realized t...
Hello,
My usual tools are Emacs with g++ on a Linux system to implement my research algorithms. For the last some years, I have used emacs in a fairly basic way. I open C or C++ files, edit them with a syntax highlighting scheme of my choice and compile and do other stuff from within emacs (or maybe from a terminal), including using gdb...
Consider the following code:
class myarray
{
int i;
public:
myarray(int a) : i(a){ }
}
How can you create an array of objects of myarray on stack and how can you create an array of objects on heap???
...
I am using libjpeg for decode jpeg file.
when decoding a large image, user may switch to another jpeg file, So is decode-interrupt supported by libjpeg?
Many thanks!
...
This code works as desired for the most part, which is to prompt the user for a single character, perform the associated action, prompt the user to press return, and repeat. However, when I enter ^D (EOF) at the prompt, an infinite loop occurs. I am clearing the error state via std::cin.clear() and calling std::cin.ignore(...) to clear...
hello, guys
I'm confused a little while writing own tiny discovering program to clear up how Visual C++ allocates the memory for dynamic arrays. I must note, I have never met technical documents that describe this question on new[]/delete[] operators for any C++ implementation.
Initially I thought that new[] and delete[] are something ...
I've inherited a fairly large C++ project in VS2005 which compiles to a DLL of about 5MB. I'd like to cut down the size of the library so it loads faster over the network for clients who use it from a slow network share.
I know how to do this by analyzing the code, includes, and project settings, but I'm wondering if there are any tools...
I am trying to create a data buffer, more specifically, an image buffer, which will be shared among multiple modules. Those modules only reads from the buffer and don't communicate with each other at all. My difficulty is:
1.Large data size:
larger than 10M per image, that means copying those data around for different threads is not...
Hello,
I have to send mesh data via TCP from one computer to another... These meshes can be rather large. I'm having a tough time thinking about what the best way to send them over TCP will be as I don't know much about network programming.
Here is my basic class structure that I need to fit into buffers to be sent via TCP:
class Pr...
I have some programs that use MapViewOfFile to share data, but I am getting strange access violations that seem to be from accessing the mapped file data.
Some of the shared data has pointers, however these pointers are only set and used by one process, but by several threads within the process.
I understand that you can't use pointer...
Of what I know of benefits of using initialization list is that they provide efficiency when initializing class members which are not build-in. For example,
Fred::Fred() : x_(whatever) { }
is preferable to,
Fred::Fred() { x_ = whatever; }
if x is an object of a custom class. Other than that, this style is used even wit...
Ive got a problem that if I have a template class, which in turn has a template method that takes a parameter of another instance of the class (with different template arguments), that it can not access protected or private members of the class passed as a parameter, eg:
template<typename T>class MyClass
{
T v;
public:
MyClass(T...
Consider the following :
int increment1 (const int & x)
{ return x+1; }
int increment2 (const int x)
{ return x+1; }
I understand passing references to class objects an such, but I'm wondering if it's worth to pass reference to simple types ? Which is more optimal ? Passing by reference or passing by value (in case of a simle type?)
...
Continuing the question in:
http://stackoverflow.com/questions/1587521/keep-windows-trying-to-read-a-file
Thanks to accepted answer in that question I realized that keeping windows waiting for data is a driver responsability.
As i'm using Dokan, I am be able to look into the driver code. Dokan complete the IRP request with a STATUS_EN...
Im using the Qt library. I'm currently trying to create my own QDockWidget (the class MY class is inheriting). Right now MY class has an ptr to QDockWidget. Does this even make sense? is that a legal statement? is there a better way to separate the QDockWidget from the rest of my program in Qt? Im a little lost on how to implement a new ...
Windows has an option to open a file with exclusive access rights. Unix doesn't.
In order to ensure exclusive access to some file or device, it is common practice in unix to use a lock file usually stored in the /var/lock directory.
The C instruction open( "/var/lock/myLock.lock", O_RDWR | O_CREAT | O_EXCL, 0666 ) returns -1 if the l...
How can I hide the default constructor from consumers? I tried to write in private but got compilation issues.
solution is:
class MyInterface
{
public:
MyInterface(SomeController *controller) {}
};
class Inherited : public MyInterface
{
private:
Inherited () {}
public:
Inherited(SomeController *con...
I have written a multithreaded program which does some thinking and prints out some diagnostics along the way. I have noticed that if I jiggle the mouse while the program is running then the program runs quicker. Now I could go in to detail here about how exactly I'm printing... but I will hold off just for now because I've noticed that ...