c++

hashing a dictionary in C++

hi I want to use a hashmap for words in the dictionary and the indices of the words in the dicionary. What would be the fastest hash algorithm for this? Thanks! ...

Counting program unaligned address accesses on Sun OS, AIX

How to count program unaligned address accesses on Sun OS and AIX. Or how to measure time to system handling this exception on Sun OS and AIX ? ...

Two static libs, two different vector implementations, what would the linker do?

Imagine that we have two static libraries built with different implementations of std::vector. Both of these binaries would have the code for both push_back and pop_back (since vector is usually header only). What would the linker do when we tried to use both of these libraries in a project. Would it give an error? Could the linker remo...

About pointer and reference syntax

Embarrassing though it may be I know I am not the only one with this problem. I have been using C/C++ on and off for many years. I never had a problem grasping the concepts of addresses, pointers, pointers to pointers, and references. I do constantly find myself tripping over expressing them in C syntax, however. Not the basics lik...

Boost Property Tree with filename as key

I am trying to use filenames as the key in boost::PropertyTree However, the '.' character in a filename such as "example.txt" causes an additional layer to be added within the property tree. The most obvious solution would be to replace '.' with another character, but there is likely a better way to do this, such as with an escape char...

How to turn type-labeled tokens into a parse-tree?

So I'm writing a programming language in C++. I've written pretty much all of it except for one little bit where I need to turn my tokens into a parse tree. The tokens are already type labeled and ready to go, but I don't want to go through the effort of making my own parse tree generator. I've been looking around for apps to do this bu...

3d convolution in c++

Hello, I'm looking for some source code implementing 3d convolution. Ideally, I need C++ code or CUDA code. I'd appreciate if anybody can point me to a nice and fast implementation :-) Cheers ...

Subscribe a button to trigger some function dynamically in C++ ?

Hello, I'm trying to make a button class (abstract) so I can set what function is that button going to trigger when clicked dynamically when my program load. I want to construct all my buttons by reading XML files, this is to avoid code replication so having only 1 "generic" button class is really useful for me. I was wondering if you ...

Upcasting pointer reference

I have the following contrived example (coming from real code): template <class T> class Base { public: Base(int a):x(a) {} Base(Base<T> * &other) { } virtual ~Base() {} private: int x; }; template <class T> class Derived:public Base<T>{ public: Derived(int x):Base<T>(x) {} Derived(Derived<T>* &other): Base<T>(other) {} ...

Remote developing with Eclipse

Hi. I'm trying to set-up a remote C++ development with Eclipse Galileo, but just can't make it work. Trying the NetBeans 6.8 worked almost out of box, as described in this article: http://netbeans.org/kb/docs/cnd/remotedev-tutorial.html Is there any good article or tutorial, explaining how to setup such environment with Eclipse? Than...

Malloc call on delete[] showing up as memory leak in totalview

I am using HDF5 to read a string in to a char* allocated by new[]. I then use a string::assign() call to copy this data to where I actually want it. I then call delete[] on that char*. This is showing up as the source of a memory leak using totalview. It shows mangled calls in stdlibc++ under delete[] to replace_safe, mutate, create,...

Would you use num%2 or num&1 to check if a number is even?

Well, there are at least two low-level ways of determining whether a given number is even or not: 1. if (num%2 == 0) { /* even */ } 2. if ((num&1) == 0) { /* even */ } I consider the second option to be far more elegant and meaningful, and that's the one I usually use. But it is not only a matter of taste; The actual performance ma...

how to look up hash_map in C++?

Here's what I have, I am new to C++ so I am not sure if this is right... typedef pair<string, int>:: make_pair; hash_map <string, int> dict; dict.insert(make_pair("apple", 5)); I want to give my hash_map "apple", and I want to get back 5. How do I do it? ...

Are all members of following structs and arrays initialized with zero?

Furthermore, is there a difference between the initialization of the variables one and two, and the initialization of the varibles three and four? Background of the Question is, that i get an compiler error in Visual Studio 6.0 with the initialization of variable two and four. With Visual Studio 2008 it compiles well. struct stTest { ...

How do I make a full screen scrolling messagebox or window?

Hi First let me start of saying I know absolutely nothing about c++ and I am really just more interested in getting this to work then learning c++(I got enough on my plate to learn). So basically I am trying to make a terms of service for my windows mobile 6 professional application but it seems I need to use c++ to do it. After hours ...

#define NULL NULL

#ifndef NULL #define NULL NULL #endif This code compiles in gcc with no warnings/errors. Can someone explain what the preprocessor is doing here? ...

How to know calculate the execution time of an algorithm in c++?

Hi, I want to test which data structure is the best by looking at the run-time performance of my algorithm, how do I do it? For example I already have a hashmap<string, int> hmp; assuming I have "apple" in my hashmap I want to know how long the following statement takes to execute: hmp["apple"]. How can I time it? Thanks! ...

Writing BLOB data to a SQL Server Database using ADO

I need to write a BLOB to a varbinary column in a SQL Server database. Sounds easy except that I have to do it in C++. I've been using ADO for the database operations (First question: is this the best technology to use?) So i've got the _Stream object, and a record set object created and the rest of the operation falls apart from there...

In need of a SOCKS5 server library

I'd like help finding a library that adds SOCKS5 server functionality to my program. Please note, I do not want to connect to a SOCKS proxy server; rather, I want to actually run a SOCKS proxy server within my program. While there appears to be many SOCKS servers, they certainly were not built with the intention of being used as librari...

How to use a hash_map with case insensitive unicode string for key?

I'm very new to STL, and pretty new to C++ in general. I'm trying to get the equivalent of a .NET Dictionary<string, value>(StringComparer.OrdinalIgnoreCase) but in C++. This is roughly what I'm trying: stdext::hash_map<LPCWSTR, SomeStruct> someMap; someMap.insert(stdext::pair<LPCWSTR, SomeStruct>(L"a string", struct)); someMap.find(L...