Hello,
Using GCC 4.2.
I have this metatemplate for conditional type:
template <bool condition, typename Then, typename Else>
struct IF
{
typedef Then RET;
};
template <class Then, class Else>
struct IF<false, Then, Else>
{
typedef Else RET;
};
and when I use it like this:
template <typename T>
class Param
{
IF< sizeof(i...
I have an stl unordered_map and I would like to store references to elements in that map. I would like there to be no duplicate references. I thought I could create an set of iterators which pointed to elements. For one I wasn't sure that it would recognise , but even so I got some long template errors which I think boiled down to the...
Hello, I can't understand why does this code fail with segfault:
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(int argc, char** argv) {
map <string, string> temp;
map <string, string>::iterator it;
S
string text = "";
string thatChange = "";
str...
How to analyze these two following lines of code?
w += /* 28 + */ y % 4 == 0 && (y % 100 || y % 400 ==0);
and
w += 30 + (i % 2 ^ i >= 8);
Thanks.
...
Given an abstract interface and an implementation derived from that interface, where constructors are protected (creation of these objects only being available from a class factory - to implement a DI pattern), how can I make use of make_shared in the factory function?
For example:
class IInterface
{
public:
virtual void Me...
I tried the following code:
int main()
{
int x {23.22};
}
which includes an initialization that requires narrowing, but the code compiles fine without any error or warning. On the other hand, the following code gives error:
int main()
{
int x[]{23.22};
}
Have I found a bug or what?
PS: I'm currently using GCC 4.5.0
...
Is it possible for code that meets the following conditions to produce different outputs for each run for the same input?
The code is single threaded, though
it does link against a thread-safe
runtime library.
There are no explicit calls to rand() or time() or their friends.
There are some heap memory allocations.
There might be some...
I had a need to do a case insensitive find and found the following code which did the trick
bool ci_equal(char ch1, char ch2)
{
return toupper((unsigned char)ch1) == toupper((unsigned char)ch2);
}
size_t ci_find(const string& str1, const string& str2)
{
string::const_iterator pos = std::search(str1. begin ( ), str1. end ( ), st...
Hi,
How can I know, by using C++ code, which user runs a specific service? The program I need to write might run under a local administrator account, so I guess there won't be permissions problems.
Is it possible?
TIA.
...
I have question when I compile an inline function in C++.
Can a recursive function work with inline. If yes then please describe how.
I am sure about loop can't work with it but I have read somewhere recursive would work, If we pass constant values.
My friend send me some inline recursive function as constant parameter and told me t...
What is the best way for, using WinApi, find a given control in a external program window?
For example, I'm trying to change Internet Explorer's url text box. I am having trouble getting programatically the handle to the text box. I know its type is "Edit" but I'd like to avoid having to search through all the child windows for the "Edi...
I have a nested set of ints but I cannot insert elements into the nested sets.
std::set<std::set<int> > centre_as_set = bitset_to_set(centre->second->bit_partitions);
std::set<std::set<int> >::iterator set_itr;
for ( set_itr = centre_as_set.begin(); set_itr != centre_as_set.end(); ++set_itr ) {
set_itr->insert(4);
std::set<int>:...
The following small example shows my problem:
template<class T> struct X
{
static void xxx(T& x) { }
static void xxx(T&& x) { }
};
int main(int argc, char** argv)
{
int x = 9;
X<int>::xxx(x); // OK.
X<int&>::xxx(x); // ERROR!
return 0;
}
Error message (GCC):
error: ‘static void X::xxx(T&&) [with T = int&]’...
Hey,
I recently took some code that tracked an object based on color in opencv c++ and rewrote it in the python bindings.
The overall results and method were the same minus syntax obviously. But, when I perform the below code on each frame of a video it takes almost 2-3 seconds to complete where as the c++ variant, also below, is insta...
I have all kind of scripting with Ruby:
rails (symfony)
ruby (php, bash)
rb-appscript (applescript)
Is it possible to replace low level languages with Ruby too?
I write in Ruby and it converts it to java, c++ or c.
Cause People say that when it comes to more performance critical tasks in Ruby, you could extend it with C. But the wor...
Hi,
I am troubled with the following concept:
Most books/docs describe how robust servers are multithreaded and that the most common approach is to start a new thread to serve each new client. E.g. a thread is dedicated to each new connection. But how is this actually implemented in big systems? If we have a server that accepts requests...
Hi all.
I'm trying to write own jabber bot on c++/gloox. Everything goes fine, but when internet connection is down - bot thinks that it's still connected, and when connection is up again - of course bot doesn't respond to any message.
Each time since bot is successfully connected gloox' recv() returns ConnNoError, even if interface is...
Most of the requirements for a game programming job I've looked at required good C/C++ skills. I agree, most game engines are written in C/C++. But aren't the engines USED in a scripting languages? Don't the companies need scripting programmers to actually code the game from the game engine?
Why haven't I ever seen a company that requir...
I need to write a standalone (not under XULRunner) c/c++ application (Windows OS) that uses XUL as its backend GUI library.
If it is possible, can you give me a link to an example application ? I saw something about libXul, is it needed ? where can i find it ?
TNX, Vertilka
...
Hello,
I am planning to use an Arduino programmable board. Those have quite limited flash memories ranging between 16 and 128 kB to store compiled C or C++ code.
Are there ways to estimate how much (standard) code it will represent ?
I suppose this is very vague, but I'm only looking for an order of magnitude.
...