I'm implementing a custom container with an STL-like interface. I have to provide a regular iterator and a const iterator. Most of the code for the two versions of the iterators is identical . How can I avoid this duplication?
For example, my container class is Foo, and I'm implementating FooIterator and FooConstIterator. Both of th...
I'm running a program and redirecting cout to an outfile, like so:
./program < infile.in > outfile.o
I want to be able to read in an option ('-h' or '--help') from the command line and output a help message to the terminal. Is there a way I can do this but still have the regular cout from the rest of the program go to the outfile?...
I'm looking to implement a custom implementation of COM in C++ on a UNIX type platform to allow me to dynamically load and link object oriented code. I'm thinking this would be based on a similar set of functionality that POSIX provides to load and call dll's ie dlopen, dlsym and dlclose.
I understand that the general idea of COM is ...
I am doing some performance tests for the amount of time it takes to write X amount of files to a specified location. I will be comparing write speeds: 1) with a custom file system driver installed and loaded, and 2) with the file system driver not installed nor loaded.
I want to test this on various machines with various OS's. Also, I ...
(from reading chapter 3 of modern c++ design)
typelist.hpp:
class NullType {};
struct EmptyType {};
template <class T, class U>
struct Typelist
{
typedef T Head;
typedef U Tail;
};
#define TYPELIST_1(T1) Typelist<T1, NullType>
#define TYPELIST_2(T1, T2) Typelist<T1, TYPELIST_1(T2) >
#define TYPELIST_3(T1, T2, T3) Typelist<T1, T...
I'm wondering whether making files read-only so the user can't mess with them will disallow my program from writing information to them via an fstream.
...
Here,
http://stackoverflow.com/questions/2150618/how-do-i-fix-this-c-typelist-template-compile-error
we built a typelist, using the code from modern c++ design.
Question is now -- how do I take this and built it into a variant class?
Thanks!
...
Both arguments are guaranteed to be integers.
How do I write myMax such that:
myMax<1, 2>; // 2
myMax<3, 2>; // 3 ?
I want this to be evaluated at compile time, not run time. (Need to then use this with sizeof for a typelist to allocate space for a variant.)
Thanks!
...
I've got a template class with a template method within it, giving two template parameters T and U. The operation is quite expensive and is showing up in profiling to be a major use of CPU time. I could optimise it somewhat, but only for the case where T == U (which is fairly common), however I'm not sure on the syntax for doing this...
...
Modern C++ design only gets me to typelists.
C++ templates the complete guide brings me only to tuples.
I want to learn how to _implement variants.
Does any C++ book explains this?
Thanks!
...
By default, the QAbstractTableModel class has a mimeData() function that returns a QMimeData object which has it's data set as an encoded QModelIndexList (see here). I would like to unpack this data in an overloaded dropMimeData() function, but can't figure out how to convert this QMimeData back into a QModelIndexList. I tried the obviou...
I want to write something that will take care of:
If possible the int main() loop, as in, I want the code for the main function located in this file
Some mundane tasks like creating windows, initializing various things like opengl, opencv and what not.
Various "events" (I quote because I what the c++ concept of events is) for things l...
I am following some beginner tutorials for OpenGL in c++ but as I started off as a c# programmer it has made me take a lot of things for granted. So my problem occurred when I was debug printing my FPS reading to the output. I think the method was something like DebugPrintString off the top of my head which took a char* and basically i w...
#include<stdio.h>
int main()
{
unsigned char c;
c = 300;
printf("%d",c);
return 0;
}
Is the output in any way predictable or its undefined??
...
Hi, I'm overriding the new operator to manually allocate heap space when using the new keyword.
Usually using a stack-allocated heap container with pointers to its items-
CArray<CObject*> objects;
-is fine. but I'm picky and I want to make buffers-
CArray<CObject> objects;
-that let me modify POD types. So, I allocate them on the ...
I have a listwidget with items which have icons. When the item is selected both the text and the icon are highlighted. My problem is that when the icon is highlighted it just goes entirely black because I'm using only two colours. Is there a way to prevent the icon from being selected?
...
I'm downloaded the Java EE version of Eclipse 3.5.1. Can I now use it to edit C/C++ with the proper plugin?
I went to Help >> Install New Software but I don't know which URL to use to get the C/C++ plugin. I can't find it on the Eclipse website either.
...
I think meta programming is very very cool. In particular, I love lisp macros.
However, I think C++ template suck because:
1) they slow down compile time (even with precompiled headers that end up being 50MB big if you include any of he STL stuff).
2) they give terrible compiler/syntax errors that are counintuitive
3) they weren't desin...
Is it possible to make a call/notification to a C++ application from Microsoft SQL Server?
To give a broader understanding of what I'm trying to achieve: our database is being updated with new information; Whenever a new piece of information is received, we'd like to push this to the C++ application so that its dashboard reflects up-to...
Hi,
I'm a programming student, and I've now had two classes in C#, this semester I'm taking my first C++ class.
Out of curiosity, is it possible to call a C# application from a C++ application?
If so, is it also possible to check if the computer running the program has the .NET framework?
I'm just curious, and I think if its possib...