I would like to provide a templated function, that varies its implementation (->specialization) according to the sizeof the template type.
Something similar to this (omitted typecasts), but without the if/elseif:
template<class T>
T byteswap(T & swapIt)
{
if(sizeof(T) == 2)
{
return _byteswap_ushort (swapIt);
}
...
Hi there.
How To Programmatically Create a User's Profile from the NetworkServices account at
WinServer 2008 r2.
THX, Alex
...
I was looking at std::numeric_limits<float>::min/max() but it appears 'min()' returns the smallest absolute value, not the lowest value. Is it safe to use
-std::numeric_limits<float>::max(), i.e is float symmetric in min/max limits?
...
I've recently been doing a huge refactoring where I was changing a lot of my code to return booleans instead of an explicit return code. To aid this refactoring I decided to lean on the compiler where possible by getting it to tell me the places where my code needed to be changed. I did this by introducing the following class (see here...
This question is related to this question. The following code compiles fine VC9 compiler but gives the error when compied with Comeau online. Can anybody tell me which one is correct and what is the meaning of the error?
error: ambiguous "?" operation: second
operand of type "TypesafeBool" can be
converted to third operand type
...
void trim(string &str)
{
string::iterator it = str.begin();
string::iterator end = str.end() - 1;
// trim at the starting
for(; it != str.end() && isspace(*it); it++)
;
str.replace(str.begin(), it, "");
// trim at the end
for(; end >= str.begin() && isspace(*end); end--)
;
str.replace(str...
I have a console application from which I create a window.
I can render stuff in the window just fine. But the window is unresponsive/uncontrollable by the user.
As soon as you mouse over the window you get the hourglass cursor and cannot move the window.
What might be causing this?
EDIT:
WNDCLASSEX wndClass; // Window...
So I have a folder with boost 1.44.0 and I need both msvc and MinGW binary libraries. I have already done the msvc build and need to do the MinGW gcc build next. Can I build from the same folder? My reasoning is this should not create a problem as the .a/.so libraries are just placed in the same lib folder but the headers/sources and not...
I've written a collection of data structures and functions in C, some of which use the _Bool data type. When I began, the project was going to be pure C. Now I am investigating using a C++ based GUI tool kit and have made the backend code into a library.
However, when compiling the C++ GUI the following error is emitted by the compiler:...
This is not only a question, this is also a call for help.
Since I started my career as a programmer, I always tried to learn from my mistakes. I worked hard to learn best-practices and while I don't consider myself a C++ expert, I still believe I'm not a beginner either.
I was recently hired into a company for C++ development. There I...
When I wrap up some procedural code in a class (in my case c++, but that is probably not of interest here) I'm often confused about the best way to do it. With procedural code I mean something that you could easily put in an procedure and where you use the surrounding object mainly for clarity and ease of use (error handling, logging, tr...
Hi,
I am working in migration project from VC6 to VC9. In VC9 (Visual Studio 2008), I got compilation error while passing const member to a method which is accepting reference. It is getting compiled without error in VC6.
Sample Program:
class A
{
};
typedef CList<A, A&> CAlist;
class B
{
CAlist m_Alist;
public:
const B& op...
Hi! Using the Ogre3D engine (C++), I would like to generate a mesh from a grayscale heightmap. I know that the Terrain tools can do that but I just want a simple mesh. What would be the best way to do that? This sounds pretty basic but I can't find my way in the Ogre3d doc.
Thanks!
...
Possible Duplicate:
The Definitive C++ Book Guide and List
I'm in the process of learning C, and am reading the K&R book thoroughly and trying to do as many of the exercises as possible.
I'm looking at picking up C++ after I'm comfortable with C. Is there a de facto C++ book? Particularly one with good exercises?
Thanks
...
I have recently managed to get a stack overflow when destroying a tree by deleting its root 'Node', while the Node destructor is similar to this:
Node::~Node(){
for(int i=0;i<m_childCount;i++)
delete m_child[i];
}
A solution that come up into my mind was to use own stack. So deleting the tree this way:
std::stack< Node* >...
Hi,
I am storing dynamically allocated class pointers in a vector like below.
vector<Test *> v;
Test *t1 = new Test;
Test *t2 = new Test;
v.push_back(t1);
v.push_back(t2);
Now, if i have to free Test objects, i have to loop through entire vector and free one by one and then do a clear.
for(int i = 0; i<v.size(...
In the code below:
template<typename T>
struct X {};
int main()
{
X<int()> x; // what is the type of T ?
}
What is the type of T? I saw something like this in the boost sources.
...
Hello,
My application have an asio server socket that must accept connections from a defined List of IPs.
This filter must be done by the application, (not by the system), because it can change at any time (i must be able to update this list at any time)
The client must receive an acces_denied error.
I suppose when the handle_accept ...
Hello,
I need to run SystemBus and SessionBus mainloops in my python application.
So I would like to ask what is the best way to do this ?
To run SystemBus mainloop in application's main thread and SessionBus mainloop in another ?
Regards,
Levon
...
I know this may seem like a math question but i just saw this in a contest and I really want to know how to solve it.
We have
a (mod c)
and
b (mod c)
and we're looking for the value of the quotient
(a/b) (mod c)
Any ideas?
...