Hi,
I need to automatically prepend method name to some logging messages. I've been using __FUNCTION__ to do it but it generates the fully qualified name of the method ( namespace::class:method ). So it's wasting a lot of space and makes logs less readable. Is there any way to append only the method name in a MACRO, without any unneces...
i wrote this code:
class A {
public:
A(){d=2.2;cout<<d;}
A(double d):d(d){cout<<d;}
double getD(){return d;}
private:
double d;
};
class Bing {
public:
Bing(){a=A(5.3);}
void f(){cout<<a.getD();}
private:
A a;
};
int main() {
Bing b;
b.f();
}
i get the output: 2.2 5.3 5.3 instead of 5.3 5.3....
I am working on a mobile platform over Nucleus RTOS. It uses Nucleus Threading system but it doesn't have support for explicit thread local storage i.e, TlsAlloc, TlsSetValue, TlsGetValue, TlsFree APIs. The platform doesn't have user space pthreads as well.
I found that __thread storage modifier is present in most of the C++ compilers. ...
I want to use a vector to hold read-only integer-matrices of the size 5x5
vector<const int[5][5]> startingPieces;
But this declaration causes a bunch of weird errors I've never ever seen before.
error C2535: 'const int (*std::allocator<_Ty>::address(const int (&)[5][5]) const)[5][5]' : member function already defined or declared
1> ...
Hi,
I'm looking for a sample code.
It's 3D modeling using camera.
like this: http://mi.eng.cam.ac.uk/~qp202/my_papers/BMVC09/
Hopefully, I want to use c or c++.
Thanks.
...
Are there any good places to get examples for the C++ Google Style Guide?
...
I have a programming that is drawing realtime animations to a gtkmm window. I have my main thread gui thread and a worker threa that renders a frame of the animation to a image surface using cairo. The worker thread has is signaled by the main thread every 33mS. Right now I have my app creating a new rendering thread on every timeout ...
I wondering is there any way to set restrictions on template class?
Specify that every type substituted in template must have specific ancestor (realize some interface).
template < class B > //and every B must be a child of abstract C
class A {
public:
B * obj;
int f() {
return B::x + this->obj->f();
}
};
Like =>...
How this code modifies a value in a const function:
#include<iostream>
using namespace std;
class Y;
class X{
public:
void access(Y &y) const;
};
class Y{
int d;
public:
friend void X::access(Y &y) const;
Y(){d=0;}
};
void X::access(Y &y) const
{
cout<<"Y is "<<y.d<<endl;
y.d=1;
cout<<"Y is "<<y.d<<en...
Say I have a huge amount of code and have different kinds of error messages. For these, I want to have a separate place where I store error codes and error messages. For example, for an error that occured because the program could not open a file I store:
F001 "Can not open a file." "The same error message in another language" "The s...
I need to test my program on a specific environment. I want to know how I can customize the cpu or ram usage, or see what will happen when I run my program to the hardware. I need this information:
memory usage
cpu usage
...
can somebody please explain my mistake, I have this class:
class Account{
private:
string strLastName;
string strFirstName;
int nID;
int nLines;
double lastBill;
public:
Account(string firstName, string lastName, int id);
friend string pr...
Is there some plugin or tool which can read a .h file (or simply modify Intellisense itself) and spit out every function and it's virtual function table index? There's a pattern which I have yet to figure out having to do with polymorphism, and it gets 5x harder when you start to have 5 classes or more deriving from each other. No matter...
Hi there,
I've written some MPI code which works flawlessly on large clusters. Each node in the cluster has the same cpu architecture and has access to a networked (i.e. 'common') file system (so that each node can excecute the actual binary). But consider this scenario:
I have a machine in my office with a dual core processor (intel)...
Hello, how can I insert my own class objects into ptr_map from boost. The objects are templated so I can't use some static typename in the map. So I did:
ptr_map<string, any> someMap;
My class inherits the boost::noncopyable.
someMap.insert("Test", new MyClass<SomeTemplate>());
The error is: error: no matching function for call to ...
How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to uniform distribution). It is only allowed to use one static variable and at most 3 elementary steps, where each step consists of only one basic arithmetic operation of arity 1 or 2.
Example:
int myr...
My client application uses a boost::asio::ip::tcp::socket to connect to a remote server.
If the app loses connection to this server (e.g. due to the server crashing or being shutdown) I would like it to attempt a re-connect at regular intervals until it succeeds.
What do I need to do on the client-side to cleanly handle a disconnect, ti...
I am using SUSE 10 Linux on a machine with 16 G ram and 2 quad core CPUs.
There are 8 processes which are doing some work (CPU intensive/network i/o). Out of which 4 have a memory leak (These are test conditions so no problem in having leaks here).
Total space is occupied by all processes is around 15.4 G only 200 MB is free in system.
...
Possible Duplicate:
Do I need to use locking with integers in c++ threads
Do critical sections inside trivial int accessors actually do anything useful?
int GetFoo()
{
CriticalSection(crit_id);
return foo;
}
void SetFoo(int value)
{
CriticalSection(crit_id);
foo = value;
}
Is it possible for two threads to be a...
Supposing that memory is not an issue does targeting a 64 bit OS make a C/C++ Windows console application run faster?
Update: Prompted by a few comments/answers the application involves statistical algorithms (e.g., linear algebra, random number draws etc).
...