c++

where is the ublas::vector push_back ?

hi may i know where is the ublass::vector push_back or what ever does the same ? p.s (i'm not talking about std::vector) ...

Can intellisense be enabled in VS2008 within preprocessor directive blocks like #ifndef ... #endif

While working within C++ libraries, I've noticed that I am not granted any intellisense while inside directive blocks like "#ifndef CLIENT_DLL ... #endif". This is obviously due to the fact that "CLIENT_DLL" has been defined. I realize that I can work around this by simply commenting out the directives. Are there any intellisense opti...

Byte frequency table for Huffman coding

I'm writing a huffman compressor and decompressor (in C++) that needs to work on arbitrary binary files. I need a bit of data structure advice. Right now, my compression process is as follows: Read the bytes of the file in binary form to a char* buffer Use an std::map to count the frequencies of each byte pattern in the file. (This is ...

C++ beginner question: dereference vs multiply

hi, Just getting into C++. I'm getting constantly thrown off track when I see the symbol for multiply (*) being used to denote the dereferencing of a variable for example: unsigned char * pixels = vidgrabber.getPixels(); Does this throw other people off? What's the tip for getting my head around this? Thank you. p.s. I have an...

Boost xpressive error

This simple example using Boost xpressive (latest version) throws 'Access violation reading location 0x000000'. The error occurs on regex_match. This has to be something simple but I've looked it until I am crazy. Why does this not work? Is my regex wrong? Am I using xpressive wrong? Please help and thanks! using namespace boost::xpre...

Tree implementation using Lists of children in C++

Hey here is what I have so far. I am supposed to make a tree ADT implementation as lists of children. I am not sure whether what I'm doing is correct or not. Any help would be greatly appreciated. Thanks in advance. #include <string> #include <iostream> using namespace std; const int maxcells = 1000; const int maxnodes = 1000; templa...

c++ boost asio timeout for blocking connect

I have a C++ boost client that does a blocking connect and processes the message once it receives a response. I am facing a strange issue. tcp::resolver::query query(tcp::v6(), this->host, port,tcp::resolver::query::v4_mapped); iterator = resolver.resolve(query); socket = new tcp::socket(io_service); socket->connect(*iterator); I tri...

Convenient method in GoogleTest for a double comparison of not equal?

I'm looking for something similar to the ASSERT_EQ / ASSERT_NE for ASSERT_DOUBLE_EQ. Maybe I'm missing an easy way of doing this without having a ASSERT_DOUBLE_NE? ...

What are the ramifications of passing & assigning arrays as pointers in C++?

As background, I gave an answer to this post a little while ago: http://stackoverflow.com/questions/3473438/c-return-array-in-a-function/3473448#3473448 And it unintentionally kicked off a really long comment chain about pointers vs. arrays in C++ because I tried to oversimplify and I made the statement "arrays are pointers". Though m...

Using a (mathematical) vector in a std::map

Related: what can I use as std::map keys? I needed to create a mapping where specific key locations in space map to lists of objects. std::map seemed the way to do it. So I'm keying a std::map on an xyz Vector class Vector { float x,y,z } ; , and I'm making a std::map<Vector, std::vector<Object*> >. So note the key here is not ...

Thread related issues and debugging them

Hi, This is my follow up to the previous post on memory management issues. The following are the issues I know. 1)data races (atomicity violations and data corruption) 2)ordering problems 3)misusing of locks leading to dead locks 4)heisenbugs Any other issues with multi threading ? How to solve them ? ...

Which is the better convention of declaring pointers in C++? MyClass* ptr (or) MyClass *ptr?

Which is the better convention of declaring pointers in C++? MyClass* ptr (or) MyClass *ptr I find the first one meaningful, because i feel like declaring MyClass pointer rather than a MyClass and specifying a type modifier. But i see a lot of books recommending the later convention. Can you give the rational behind the convention...

Different styles of flow of program?

I am a computer science student therefore I do not know that much. I was recently talking with a friend who just got a job as a (java) software developer. He told me that in his job there is a guy who is really experienced in C++, but unfortunately every time he writes code in java, he is using the try-catch to control the flow of the ...

How to call a derived class method from a base class method within the constructor of base...

I am wondering if it is possible to call a derived class´ function from within a function called by the base constructor (shouldn´t it already be created when the code in the brackets are executed?) #pragma once class ClassA { public: ClassA(void); virtual ~ClassA(void); void Init(); protected: short m_a; short m_b; virtual voi...

Why are Crypto++ and Ruby generating slightly different SHA-1 hashes?

I'm using two different libraries to generate a SHA-1 hash for use in file validation - an older version of the Crypto++ library and the Digest::SHA1 class implemented by Ruby. While I've seen other instances of mismatched hashes caused by encoding differences, the two libraries are outputting hashes that are almost identical. For insta...

g++ linking issues: undefined reference to functions

I used CMake and Visual C++ to build the HyDE library. Then, still in VC++, I was able to successfully create code and build an executable that links into HyDE.lib and the HyDE header files. I then discovered that in order to work with others at my company, it would be preferable to develop in Eclipse CDT. Knowing very little about Ec...

boost lambda question

#include <iostream> #include <set> #include <algorithm> #include <boost/lambda/lambda.hpp> #include <boost/bind.hpp> using namespace std; using namespace boost::lambda; class Foo { public: Foo(int i, const string &s) : m_i(i) , m_s(s) {} int get_i() const { return m_i; } const string &get_s() const { return m_s; } fri...

How do I make Qt dialog get info while locking main window from user?

I have a Qt main window that will pop up a dialog box that has an OK and Cancel button. This dialog has a simple spinner that asks a user for a number that should be returned to the main window when OK or Cancel is pressed (for cancel, it will just send back -1). I thought about using code in a signal in mainWindow.cpp like so: void ma...

Overloading/specializing STL algorithms for non-local containers (database back end).

What I want to do is, in a separate namespace, define my own sort(), copy(), etc implementations that work with database tables/views/etc containers instead of in-memory std containers. If I define my own sort() that accepts my custom forward iterator, how does the compiler resolve that? Or, what do I need to do so that it will resolve...

Testing whether an iterator points to the last item?

I have an stl iterator resulting from a std::find() and wish to test whether it is the last element. One way to write this is as follows: mine *match = someValue; vector<mine *> Mine(someContent); vector<mine *>::iterator itr = std::find(Mine.begin(), Mine.end(), match); if (itr == --Mine.end()) { doSomething; } But it seems to me...