But the standard doesn't dictate that it shouldn't either, correct? Ie, the release of memory is implementation-defined?
Basically, I have a large unordered_map of POD pairs that is repeatedly...
Type: Posts; User: golfinguy4
But the standard doesn't dictate that it shouldn't either, correct? Ie, the release of memory is implementation-defined?
Basically, I have a large unordered_map of POD pairs that is repeatedly...
Oops, my mistake. I meant reserve. Good to know that reserve doesn't release memory. While clear removes items, does it release the memory the unordered_map used to store them?
In one of my projects, I'm using an unordered_map where I repeatedly clear and refill it. Each time, the number of points is roughly similar (but not identical), so preventing reallocation is...
Say I have a simple vector class...
class Vector3{
public:
Vector3();
Vector3(float* data);
Vector3 operator+(const Vector3& vec) const;
Vector3 operator-(const...
Even when cast to an unsigned int, I got the same result. I never knew shifting a uint by 32 bits was undefined. Always assumed it'd be filled with 0's.
#include <iostream>
int main(void){
unsigned int foo = 0xFFFFFFFF;
//i'd think these would return the same result, but
//they don't in visual studio 2010 (debug/release). why?...
Will the compiler even attempt to do it? Here's the example I'm working with...
//MY_HEADER_H
class Base{
public:
virtual void method1() = 0;
virtual void method2() = 0;
...
Data structures are typically dictated by the algorithm. Do you know how you plan on solving the problem? As Wikipedia will tell you, there are a few ways of analyzing it.
One of the more...
Google Code
Always a good place to look. ;)
Ah ok, you were referring to the data in the class itself. Makes sense.
However, correct me if I'm wrong, std::vectors use a contiguous block of memory and store their own copy of the data. Are you implying that the data itself may be stored non-contiguously but that...
Given a class of the form
class DataVector
{
public:
DataVector(int i, int j, int k){
_vals[0] = i;
_vals[1] = j;
And that's what I was looking for. Thanks.
Thanks brewbuck. I figured what I was doing wasn't legal, and your response confirms it. Is there an equivalent paradigm with similar encapsulation (i.e. maintaining the hidden nature of the data...
Don't worry so much about the thread-safety. I know what I'm doing there, and things will be thread-safe. I'm a semi-competent programmer who went on a bit of a hiatus so things are a bit rusty. ...
I probably should have clarified. I understand the need for some sort of data protection such as semaphores, critical sections, etc. I thought it was implicitly assumed one would be used in the...
Here's what I'm trying to do, but VS2008 isn't liking my forward declaration of the class (or friend member function for that matter).
#include <iostream>
class B;
class A {
Thanks. the NVI idiom was what I was looking for. It's been a long day...
Here's a bit of pseudocode describing the situation I'm in...
class Base{
public:
void method(){
//do some stuff
protectedFunc(foo);
Thanks Sebastiani and anon. I'll have to take a closer look at your responses tonight when I get a chance.
Sebastiani,
Specifying all of the functors at once won't be an issue. While the functors themselves use variables that change during run-time, the actual functors being used are known at...
The above pseudo-code is now accurate (and was accurate as of your last post).
Error: "error C2064: term does not evaluate to a function taking 1 arguments"
Also, even if I were to construct my...
This is just pseudo-code. I just forgot to put them in. Let me try to correct it to make it a bit more C++-ish. I should probably also note that the error I'm getting involves the functor not...
I'm looking to optimize a portion of my code that is extremely time sensitive (will be running at least 1000x/s). It involves sequentially calling a series of functions to modify a given value. To...
I'm deciding between which OS to install on a new thinkpad laptop. Already have the laptop (with vista basic) and LEGAL versions of the respective OS's. I'll be running basic math/engineering...