Hi, I've seen answers here for specific languages, about switches with more than 5 cases being optimized with jump tables to guarantee constant access time for any case.
Is that so for C / C++?
Is it in particular for gcc? for visual studio?
If not, would sorting cases in order of occurrence frequency help?
...
I have the following time :
2010-01-25 03:13:34.384 - GMT Time Zone
2010-01-25 11:13:34.384 - My Local
I wish to convert to timestamp in ms. However, since I only obtain local time string from caller
"2010-01-25 11:13:34.384"
If I do it this way :
// ts is "2010-01-25 11:13:34.384" (My Local)
boost::posix_time::ptime t(boost::posix_...
I am planning on doing a script transformation utility (for extended diagnostic information) using Boost.Spirit 2.
While there is support for line information etc. for parsing errors, how i can store line numbers for successfully parsed expressions with Qi?
...
I'm trying to understand how variants are implemented, and reading:
http://www.codeproject.com/KB/cpp/TTLTyplist.aspx
And I'm getting the impression that I can't write a variant that takes X types; but that the template writer picks some N, and I can only have less than-N types in a variant.
Is this correct?
Thanks!
...
In C++, my understanding is that virtual function can be inlined, but generally, the hint to inline is ignored. It seems that inline virtual functions do not make too much sense.
Is that right?
Can anybody give a case in which an inline virtual function is good?
...
I keep getting multiple error windows for an app i'm developing asking for ._libpal_bullet.dll when it should really be just libpal_bullet.dll. The weird thing is after I get all the error messages, the app runs anyway using the correct dlls that exist in the same directory.
How can i get rid of these errors?
...
In an effort to code the briefest solution I could for an approximation of the integral using Riemann sums, I ran into a strange problem: if the user requested a partition count in excess of 10, the program failed. Any thoughts? Here's the code:
// The Integral
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
...
If I can't call lock on a mutex in the main application thread (my event handler because you can't lock the main gui thread), how do I share any information between my worker and my main thread?
...
Hi,
I've just completed writing a program for a programming class, and I want to avoid use of magic numbers, so here's my question:
In the function below, would my array indexers be considered magic numbers?
Code:
string CalcGrade(int s1, int s2, int s3, double median)
{
const int SIZE = 23;
const int LETTER_GRADE_BARRIERS[SIZE] = { ...
Hello,
I am stuck trying to figure out how to do string hashing with linear probing.
Basically, the idea is to hash every string from a dictionary (90000 words), and retrieve anagrams of selected words.
Here's what I did:
created a hash table 2*90000 in size
using a simple hash function, I hash each word from the dictionary, get a v...
Hi,I am using boost library for logging purpose. It is working fine with x86 bit mode but is not functioning in x64 bit mode.Kindly let me know the possible solution/steps to debug and fix this issue. Thanks in advance. Regards,
Sumanta
...
You are given an integer 51234 (say) we need to sort the digits of a number the output will be 12345.
How to do it without using array ?
...
I would like my Qt app to expose a service to another app written in .Net using WCF.
Is there any support in Qt for implementing WCF services?
...
May I know how I can convert std::string, to MSVC specific __int64?
...
Hello,
I'm trying to implement this singleton class. But I encountered this error:
'Singleton::~Singleton': cannot access private member declared in class 'Singleton'
This is flagged in the header file, the last line which contains the closing brace.
Can somebody help me explain what is causing this problem?
Below is my source code.
...
I have a situation where I need to pick up files from a directory and process them as quickly as they appear. The process feeding files into this directory is writing them at a pretty rapid rate (up to a thousand a minute at peak times) and I need to pull them out and process them as they arrive.
One problem I've had is knowing that my ...
How to convert estimated time to string with ICU library?
...
The usual pattern for a ReadWriteMutex is to use a semaphore and have the writer loop to acquire all the resources:
inline void write_lock() {
ScopedLock lock(acquire_mutex_);
for (size_t i=0; i < resource_count_; ++i) {
if (sem_wait(semaphore_) < 0) {
fprintf(stderr, "Could not acquire semaphore (%s)\n", strerror(errno));...
Hi.
There is a problem: i need to compile the dll from all source *.cpp files in a particular folder with a help of nmake.
For example, cpp files stored in the folder ".\src", and they must be compiled into one dll.
Where i can read about nmake? Or some examples?
...
I have an ATL/WTL project developed using Visual Studio 2008 and up until now I have been statically linking with the CRT libraries, avoiding the need to ship them. However, I now need to consider using the dynamic libraries (DLL) instead - in order to reduce the size of the code and because I want to use the excellent crashrpt tool (wh...