Is there any performance difference between:
size.width += this->font->chars[*ch].advance + this->font->chars[*ch].offset.x;
and
char_data *chars = this->font->chars;
while(...) {
size.width += chars[*ch].advance + chars[*ch].offset.x;
}
In first example are always read vars( this->font, font->chars ) within loop, or they are ca...
Hi,
I'm using WinHTTP to write an an app that needs access to the internet, and is potentially behind a proxy. Everything works (almost) out of the box is the user is on a domain, but if he or she isn't then I need a way to ask for credentials. Is there a standard way of doing that, or should I write my own dialog?
Ideally I'd like som...
I haven't done much coding in C++, but I? noticed that I have to run these build scripts for everything. HOw do people do these on windows machines? I am thinking about running a virtual machine anyway, so I don't have to fill my machine with python and other such installations.
How does everyone else on windows do it?
...
Click here to view the problem.
I can't come to a solution better than O(n^2) but with n<=500000 this won't work!
My Idea is to sort them by (beauty+intellect+richness) and test any of them with those after it.
Please help!
...
Hi when I was trying to execute my program(c++) i was getting the following error:
a.out: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struc...
Should a Unix GUI application's warning be sent to std::cerr or std::cout?
This presumes that GUI normally presents the warnings and errors in a console window and also sends them to a log file. But in the case that the console is missing and thus cannot be used should std::cerr, std::cout, or std::clog be used for such messages?
I'm ...
Hi All,
I would like to build my own signal processing library, and possibly another one about graphs algorithm. I find C# very useful and robust in regards of possible bugs associated with memory allocation, pointers, threading etc...
But I was wondering how much am I going to lose in terms of performance. Is it going to be something a...
So, let's say, in a class in C++, I have a variety of member variables. Structs, strings, ints, etc. etc. Could be anything. These variables can or cannot be set by the initialization of the object of this class. Given int a, float b, char c, sometimes all of them or none of them can be set. When they are set, they can be set to any poss...
//Generate Food Personality
for(i=0; i<food.size(); i++)
{
srand(time(0));
int randomFood = rand() % 6;
if(randomFood == 1 || randomFood == 3 || randomFood == 5)
{
badFood.push_back(food[randomFood]);
}
else if(randomFood == 0 || randomFood == 2 || randomFood == 4)
{
goodFood.push_...
I want to erase items from the list while iterating over. I have done this before, but somehow this simple example fails me. thnx for the help in advance!
#include<iostream>
#include<list>
using namespace std;
void main()
{
list<int> x;
for ( int i =0;i<10; i++)
x.push_back(i);
for( list<int>::iterator k = x.begin(...
Hi,
I'm trying to figure out the correct way of initializing a static container variable whose template value is a private inner class. Here's a toy example
#include <vector>
using namespace std;
template <class myType>
class Foo {
private:
class Bar {
int x;
};
static vector<Bar*> bars;
};
template <class myT...
hey i am trying to understand how to overload the operator= when there is an inheritance
with no Success.
code example:
class Person
{
private:
char* m_name;
char* m_lastName;
.....
public:
virtual Person& operator=(const Person& other);
};
/********************/
cpp implementation
/****...
Why executing this code:
// DefaultAny.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <exception>
using std::cout;
template<class T>
struct NoReturnPolicy
{
static void calculate(T& result, const T& source)
{
result = source;
}
};
template<class T...
I understand that one benefit of having static member functions is not having to initialize a class to use them. It seems to me that another advantage of them might be not having direct access to the class's not-static stuff.
For example a common practice is if you know that a function will have arguments that are not to be changed, to...
I understand the behavior of const-qualified data types. I am curious, though, if there is any performance gain or loss from over- or under-zealousness of qualifying variables as const. I am thinking particularly of variables declared and used exclusively within an isolated code block. For example, something like:
const qreal padding = ...
I am trying to separate Groups from an Svg-File.
Separating single elements such as rectangles is possible via Rsvgs.
render_sub(cairo_context,"#rect1234") works well for me. Is there a way to also separate whole groups of elements you created in inkscape before?
Like render_sub(cairo_context,"#g4321") [which doesn't work].
...
I work on an open source portable C++ image compression library. Currently, my API works by exchanging pointers to byte arrays with image data. I would like to support some kind of streaming mode for better performance and memory consumption.
For this, I would like to know if there is an interface or abstract base class (part of the C+...
Hi,
I wish to compare index of an element in a std::vector to an unsigned value. If I directly compare like;
if(std::distance(...)>min_distance) // true for some
I just get a warning, but works fine. However, to get rid of the warning, if I cast min_distance to int, I do not get any comparison result (although there is)
if(std::dista...
Hi,
I am looking for how to print in C++ so that table column width is fixed.
currently I have done using spaces and | and -, but as soon as number goes to double digit all the alignment goes bad.
|---------|------------|-----------|
| NODE | ORDER | PARENT |
|---------|------------|-----------|
| 0 | 0 | ...
Hi all,
This is not a home work. I was thinking of some new questions in tree traversal and this seems to be very obvious so thought of solving it.
Question is very similar to level order traversal like BFS. In BFS, we normally travel left to right in each level of tree, but here if we are travelling left to right at level i then leve...