c++

Compile time string hashing

I have read in few different places that using c++0x's new string literals it might be possible to compute a string's hash at compile time. However, no one seems to be ready to come out and say that it will be possible or how it would be done. Is this possible? What would the operator look like? I'm particularly interested use cas...

IPP linker errors on cygwin

I've built a program that uses mkl and ipp that runs on mac and linux. I'm now building that program for Windows using cygwin and gcc, and can't get it to link. The errors I'm getting are: Warning: .drectve -defaultlib:"uuid.lib" ' unrecognized ../../../bin/libMath.a(VectorUtility.cxx.o):VectorUtility.cxx:(.text+0x95): undefi...

Create a class MAT of size m x n

Create a class MAT of size m x n. Define the following matrix operations for MAT type objects a. Addition b. Subtraction c. Multiplication. ...

What are all of the well-known virtual folder GUIDs?

There seem to be a few virtual folders which have GUIDs associated to them (control panel, desktop) - ::{00021400-0000-0000-c000-000000000046} // desktop Where the blazes are these defined? When are they used? What I want is a way to have a string which represents a virtual folder without any ambiguity. If, for instance, I were to...

How to better organize the code in C++ projects

I'm currently in the process of trying to organize my code in better way. To do that I used namespaces, grouping classes by components, each having a defined role and a few interfaces (actually Abstract classes). I found it to be pretty good, especially when I had to rewrite an entire component and I did with almost no impact on the ot...

Enumerate COM object (IDispatch) methods using ATL?

Using ATL (VS2008) how can I enumerate the available methods available on a given IDispatch interface (IDispatch*)? I need to search for a method with a specific name and, once I have the DISPID, invoke the method (I know the parameters the method takes.) Ideally I would like to do this using smart COM pointers (CComPtr<>). Is this po...

C++: Will structure be copied properly?

Hello, I have a pointer to a structure and I need to implement a method that will copy all of the memory contents of a structure. Generally speaking I need to perform a deep copy of a structure. Here's the structure: typedef struct { Size2f spriteSize; Vertex2f *vertices; GLubyte *vertex_indices; } tSprite; And here's...

C++ Compiler Error: No matching function for call

Look at the following code. What is wrong with it? The compiler gives the this error: In copy constructor person::person(person&)': No matching function for call toperson::copy(char*&, char*&)' candidates are: void person::copy(char*&, const char*&) " Here is the code: class person { public: person(); person(person ...

C++ Inherited Virtual Method Still Uses Base Class Implementation

I have a base class called Packet: // Header File class Packet { public: virtual bool isAwesome() const { return false; } } and an inherited class called AwesomePacket: // Header File class AwesomePacket : public Packet { public: virtual bool isAwesome() const { return true; } } However, when I insta...

Set character set to multi byte by using code

Is there a way to set the character set to multi byte in code. By that I mean without going into the properties of the compiler and setting it. I mean it by, well...in code. :p Thanks in advanced it would mean a lot for an answer, this has been bugging me for a while. :D ...

Concatenating strings in C++

Hi, I am rather inexperienced C++ programmer, so this question is probably rather basic. I am trying to get the file name for my copula: string MonteCarloBasketDistribution::fileName(char c) { char result[100]; sprintf(result, "%c_%s(%s, %s).csv", copula.toString().c_str(), left.toString().c_str(), right.toString().c_str()); ...

Trying to know why the OpenMP code does not parallelise

I just started learning how to use OpenMP. I am trying to figure out why the following code does not run in parallel with Visual Studio 2008. It compiles and runs fine. However it uses only one core on my quad core machine. This is part of the code that I am trying to port to a MATLAB mex function. Any pointer is appreciated. #pragma om...

Making CMake choose static linkage when possible?

I'm working on a project that's link against SOCI, which comes as both static and dynamic libraries. I'd like CMake to choose the static version when available, and dynamic otherwise. Is there a reasonable way to do this in CMake? I've come up with nothing looking through the docs so far. ...

Problem with BOOST_CHECK_CLOSE_FRACTION

I'm using the Boost::Test library, and I am trying to check if an actual percent value is close to the expected value: BOOST_CHECK_CLOSE_FRACTION( items[i].ExpectedPercent, items[i].ActualCount / totalCount, 0.05); For some reason this check fails even when the values are close enough: difference between items[i].Expected...

How to send keystrokes to a window?

im using keybd_event(); and i want use SendMessage(); to send keystroke to notepad, can this be done? ...

I have a wxwidgets that I want to add some cool effects. Using GDI would be impossibly hard. Could I use flash or something else?

I have an application that I want add some cool animations to show state changes. However, wxwidgets would be difficult because I'd have to program these animations in straight gdi. What's the best way to add these effect windows? Should I open a flash window and run a flash sequence or is maybe some other technology? Does .net have some...

Include paths not found while compiling with g++ on MacOS

I'm trying to compile the simplest program on MacOS 10.6 like: $ g++ -o hello hello.cpp the following source: #include <iostream> int main (int argc, char * const argv[]) { std::cout << "Hello, World!\n"; return 0; } I'm getting the error: hello.cpp:1:20: error: iostream: No such file or directory hello.cpp: In function ‘...

turn off screen updating in a dos batch file

I am writing a program in C++ that launches commands from the DOS operating system using the system() command. So far so good I think. But how can I turn off the screen updating in the console window that pops up so I can't see the thousands of messages that are resulting. Or, alternatively, how can I dump those messages in some oth...

Using STL Allocator with STL Vectors

Here's the basic problem. There's an API which I depend on, with a method using the following syntax: void foo_api (std::vector<type>& ref_to_my_populated_vector); The area of code in question is rather performance intensive, and I want to avoid using the heap to allocate memory. As a result, I created a custom allocator which alloc...

Trying to understand a GCC error

I have the following bit of code: #include <iostream> #include <list> #include <algorithm> #include <iterator> template<typename Iterator> void foo(Iterator begin, Iterator end) { typedef typename std::iterator_traits<Iterator>::value_type type; type smallest = (*std::min_element(begin,end)); std::cout << smallest << std::endl...