I have a standard vector of pointers.
Under what circumstances might an iterator into this vector become invalidated?
I have reason to believe that when an object is deleted, any vector iterator referencing it is thereby invalidated. This does not seem correct to me, however. I do believe this would be the standard behavior of containe...
What could cause this?
Here's the stack trace:
#0 0x0645c0f5 in std::_Rb_tree_increment (__x=0x83ee5b0)
at ../../../../libstdc++-v3/src/tree.cc:69
#1 0x0805409a in std::_Rb_tree_iterator<std::pair<std::string const, Widget*> >::operator++ (
this=0xbffff144)
at /usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4...
For various reasons (and I assure you they are valid, so no "use Cocoa" talk please), I must work with XCode, C++, OpenGL, OpenCL (with a little GLUT on the side) to rebuild a few graphics demos on Mac (coming from XP + Visual Studio 2005 development). The project was built as a Command Line Tool using "c++ stdc++".
My Program.h file co...
Is there a better way to determine the length of an std::istream than the following:
std::istream* pcStream = GetSomeStream();
pcStream->seekg(0, ios::end);
unsigned int uiLength = pcStream->tellg();
It just seems really wasteful to have to seek to the end of the stream and then seek back to the original position, especially if the st...
I've seen similar questions on here but I can't seem to apply the solutions to my problem. I have a variable called $results which I got from an API. I'll change the proper nouns so as to protect my work's customers:
stdClass Object
(
[out] => stdClass Object
(
[count] => 2
[transactions] => stdClas...
Why when I entered the loop below and I type something the first instruction
cmdstd:getline(std::cin,cmdInput); does not read the input entered. For instance if I entered "b 8" it should display "cmd is b 8", but it skips to the next read std::getline(std::cin, input); and displays "it is b" instead
while (editingMode == TRUE) {
std...
Hello,
I have a variant bstr that was pulled from MSXML DOM, so it is in UTF-16. I'm trying to figure out what default encoding occurs with this conversion:
VARIANT vtNodeValue;
pNode->get_nodeValue(&vtNodeValue);
string strValue = (char*)_bstr_t(vtNodeValue);
From testing, I believe that the default encoding is either Windows-1252...
!!!!solved!!! - VS2010 has a bug, works fine with eclipse Galileo
I am working on the 'driver' part of my programing assignment and i keep getting this absurd error - error C2065: 'cout' : undeclared identifier
I have even tried using the std::cout but i get another error that says: IntelliSense: namespace "std" has no member "cout...
I have a file that I read from, it contains a bunch of lines each with a different number of integers, I'm having trouble splitting it up into a vector of a vector of ints.
This is my current code.
std::vector<int> read_line()
{
std::vector<int> ints;
int extract_int;
while((const char*)std::cin.peek() != "\n" && std::cin.p...
We've got a reasonable sized C++ application that's pretty old at this stage, so it's got a few quirks.
One of these quirks is in how it deals with C++ compilers that use a pre-standisation standard library. There's one header file that's supposed to resolve any differences between a standards compliant compiler and this one non-compl...
I'm writing some code that utilizes the boost filesystem library. Here is an excerpt of my code:
artist = (this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) ? (*(paths_iterator->parent_path().end() - 1)) : (*(paths_iterator->parent_path().end() - 2));
album = (this->find_diff(paths_iterator->parent_path(), this->m...
Hi,
I have a std::queue that is wrapped as a templated class to make a thread-safe queue. I have two versions of this class: one that stores value types, one that stores pointer types.
For the pointer type, I'm having trouble deleting the elements of the queue on destruction. The reason is that I don't know a way to remove the items fr...
I'm sure I'm making this harder than it needs to be.
I have a vector...
vector<Joints> mJointsVector;
...comprised of structs patterned after the following...
struct Joints
{
string name;
float origUpperLimit;
float origLowerLimit;
};
I'm trying to search mJointsVector with "std::find" to locate an individual joint...
I'm trying to start using namespaces the correct (or at least best) way.
The first thing I tried to do was to avoid putting using namespace xxx; at the beginning of my files. Instead, I want to using xxx::yyy as locally as possible.
Here is a small program illustrating this :
#include <iostream>
#include <cstdlib>
#include <ctime>
in...
I have a function that translates data using std::map
struct HistoParameter
{
int nbins;
float first;
float last;
HistoParameter(int _nbins, int _first, int _last) :
nbins(_nbins), first(_first), last(_last) {};
};
HistoParameter* variable_to_parameter(char* var_name)
{
std::map<const std::string, HistoParameter*> hp;
h...
I have an object that I want to be able to stream. But I want to be able to stream it in different ways by using different formats, or should I say ways to describe this object. And I wonder how this is supposed to be solved with streams.
What I want is to be able to use a generic format and use some kind of format adapter to transform...
I'm aware there are several XML libaries out there, but unfortunately, I am unable to use them for a school project I am working on.
I have a program that created this XML file.
<theKey>
<theValue>23432</theValue>
</theKey>
What I am trying to do is parse out "23432" between the tags. However, there are random tags in the file so ...
What is the difference regarding memory allocation and efficiency between using a struct with two fields and a pair?
...
Hi guys, I have to format std::string with sprintf and send it into file stream. How can I do this?
...
Hey,
I'm looking for a standard dual-map structure - is there one implemented in std/boost/another standard C++ library?
When I say "dual-map" I mean a map which can be indexed efficiently both by the key and the "value" (it actually has two key types instead of one key type and one value type).
for example:
dualmap<int,string> m;
m[1...