Default args in template
Is it possible to have something like this: template<class T = unsigned = 64> class X { }; Which basically says that if nothing is specified then unsigned should be the type and its value should be 64. ...
Is it possible to have something like this: template<class T = unsigned = 64> class X { }; Which basically says that if nothing is specified then unsigned should be the type and its value should be 64. ...
In my C++ application I sometimes create different output files for troubleshooting purposes. Each file is created at a different step of our pipelined operation and it's hard to know file came before which other one (file timestamps all show the same date). I'm thinking of adding a global counter in my application, and a function (wit...
I have a templated class Matrix. I want to specialize a function for the type complex, where T can be anything. I have tried this : 6 template <typename T> 7 class Matrix { 8 public : 9 static void f(); 10 }; 11 template<typename T> void Matrix<T>::f() { cout << "generic" << endl; } 12 template<> v...
My code dumps a hell amount of data on the command prompt. How do I activate the 'MORE' option for the output so that I see the output page by page? (MS Visual Studio) For eg. Matlab has the command 'more on' to do the same! Thanks. ...
I know how this algorithm works, but cant decide when to use which algorithm ? Are there some guidelines, where one better perform than other or any considerations ? Thanks very much. ...
I don't have my Effective C++ with me and this is bugging me so much that I have to ask for my own sanity. Given class Foo : public Bar{} void MyFunc(Bar &_input); If I pass in a Foo, am I tangling with the slicing problem or have I avoided it? ...
Is it valid to store the return value of an object in a reference? class A { ... }; A myFunction() { A myObject; return myObject; } //myObject goes out of scope here void mySecondFunction() { A& mySecondObject = myFunction(); } Is it possible to do this in order to avoid copying myObject to mySecondObject? myObject is not...
I have a C++ object, Graph, which contains a property named cat of type Category. I'm exposing the Graph object to PHP in an extension I'm writing in C++. As long as the Graph's methods return primitives like boolean or long, I can use the Zend RETURN_*() macros (e.g. RETURN_TRUE(); or RETURN_LONG(123);. But how can I make Graph->ge...
HI, I would like to profile my c++ application on linux. I would like to find out how much time my application spent on CPU processing vs time spent on block by IO/being idle. I know there is a profile tool call valgrind on linux. But it breaks down time spent on each method, and it does not give me an overall picture of how much time ...
I have three classes: class Rtss_Generator { int mv_transfersize; } class Rtss_GenSine : Rtss_Generator class Rtss_GenSineRpm : Rtss_GenSine Rtss_GenSine creates a thread in his constructer, it is started immediatly and the threadfunction is off-course declared static, waiting for an event to start calculating. the problem: all t...
I don't understand templates really and was trying to run a simple find the minimum for ints, doubles, chars. First question, why is template<typename T> sometimes used, and other times template<>? Second question, I do not know what I am doing wrong with the following code below: #include <iostream> template <typename T> T minimum...
Hi I have application that I compiled with VS 2008 on windows 7 with c++ And I got exception I trying to catch this I created pdb file (because I compiled in release) . and see part of the stack ,but it doesn't give me hints on where the error. Im looking for free ways to get this error .can you recommend on free ways to do this? ...
Hello everyone, I've not visited this site with a question, so I'm a bit clumsy with the interface, but here goes... When I examine the code generated by gcc -v -o proggy.exe proggy.o I find that the command line expands into a large bunch of library options and libraries, all of which are linked using collect2.exe. What happened to ...
Suppose I have a C(++) function taking an integer, and it is bound to (C)python with python api, so I can call it from python: import c_module c_module.f(10) now, I want to parallelize it. The problem is: how does the GIL work in this case? Suppose I have a queue of numbers to be processed, and some workers (threading.Thread) working ...
I am using SAX2 from Xerces-C to read an XML document. However, I would like to check the Doctype declaration (if there is any) to make sure that the XML file is in the format I am expecting. I have tried the unparsedEntityDecl and notationDecl methods from the DTDHandler, and EntityResolver seems to be more low-level than what I am loo...
I have a program that I need to read in an array of strings from a file. The array must be C type strings (char * or char[]). Using the following code, I get a bad access error: for (i = 0; i < MAX_WORDS && !inputFile.eof(); i++) { inputFile >> words[i]; } words is declared as: char *words[MAX_WORDS]; ...
We are moving large amounts of data on a LAN and it has to happen very rapidly and reliably. Currently we use windows TCP as implemented in C++. Using large (synchronous) sends moves the data much faster than a bunch of smaller (synchronous) sends but will frequently deadlock for large gaps of time (.15 seconds) causing the overall trans...
The following example is working when I manualy replace T wirh char *, but why is not working as it is: template <typename T> class A{ public: A(const T _t) { } }; int main(){ const char * c = "asdf"; A<char *> a(c); } When compiling with gcc, I get this error: test.cpp: In function 'int main()': test.cpp:10: error: invali...
I wrote a sparse vector class (see #1, #2.) I would like to provide two kinds of iterators: The first set, the regular iterators, can point any element, whether set or unset. If they are read from, they return either the set value or value_type(), if they are written to, they create the element and return the lvalue reference. Thus, ...
I'm reading in my text book about virtual functions in C++ and my book doesn't elaborate on what exactly run-time binding is. It doesn't give me any information as to why I would need run-time binding. Maybe the nice people at SO can provide me with some links or information? Thanks :] ...