Hi, I use one library which is very important and untouchable.
The problem is that library declare min, max function,
so when I include STL header in project, they conflict.
I want to disable min, max function in STL (like #define NOMNMAX) if I could.
If I can't, what would be solution?
Important :
Sorry, It's not Macro. Two functions a...
It is easy given a container to get the associated iterators, example:
std::vector<double>::iterator i; //An iterator to a std::vector<double>
I was wondering if it is possible, given an iterator type, to deduce the type of the "corresponding container" (here I am assuming that for each container there is one and only one (non-const) ...
Declared a map early on:
map<char*,char*> rtable; // used to store routing information
Now I'm attempting to display the contents of the map:
void Routes::viewroutes(){
typedef map<char*, char*>::const_iterator iter;
for (iter=rtable.begin(); iter != rtable.end(); ++iter) {
cout << iter->second << " " << iter->firs...
I have a class symbol_table that has a vector of objects of another class row_st.also I have an enter method where inserts objects of row_st with a passed name into the vector of desired symbol_table.but when I call the enter to enter objects with name :
a;b;c;Iwill get the following result: a,b,c;b,c;c.the first element of vector gets t...
i just moved from C to C++, and now work with lists.
i have a class called "message", and i need to have a class called "line",
which should have a list of messages in its properties. as i learned, the object's properties should be initialized in the constructor's initialization list, and i had the "urge" to initialize the messages list ...
I have an interface which is used like the following:
if (SUCCEEDED(pInterface->GetSize(&size))
{
wchar_t tmp = new wchar_t[size];
if (SUCCEEDED(pInterface->GetValue(tmp, size)))
{
std::wstring str = tmp;
// do some work which doesn't throw
}
delete[] tmp;
}
Is it safe and portable to do this instea...
What is really the difference between the algorithms remove and remove_if and the member function erase?
Does both of them result in a call to the removed objects destructor?
...
std::map<int, int> * mp = new std::map<int, int>;
for(int i = 0; i < 999999; i++){
mp->insert(std::pair<int, int>(i, 999999-i ));
}
p("created");
//mp->clear(); - doesn't help either
delete mp;
p("freed");
The problem is: "delete mp" doesn't do anything. To compare:
std::vector<int> * vc = new std::vector<int>;
for(int i = ...
I'm trying to learn templates and I've run into this confounding error. I'm declaring some functions in a header file and I want to make a separate implementation file where the functions will be defined. Here's the code that calls the header (dum.cpp):
#include <iostream>
#include <vector>
#include <string>
#include "dumper2.h"
int ...
I am using hash_map in application as
typedef hash_map<DWORD,CComPtr<IInterfaceXX>> MapDword2Interface;
In main application I am using static instance of this map
static MapDword2Interface m_mapDword2Interface;
I have got one crash dump from one of the client machines which point to the crash in clearing this map
I opened that cra...
What advantages have STL iterators? Why programmers created that notion?
...
FYI: no boost, yes it has this, I want to reinvent the wheel ;)
Is there some form of a selective iterator (possible) in C++? What I want is to seperate strings like this:
some:word{or other
to a form like this:
some : word { or other
I can do that with two loops and find_first_of(":") and ("{") but this seems (very) inefficient t...
Hi!
I allready searched on the web for it but I didn't get satisfying results.
I want to create something like
vector< vector<int*> > test_vector;
How do i fill this vector of vector? How to acces it's members? Maybe someone knows some nice tutorials on the web?
kind regards
mikey
...
auto_ptr on wikipedia said that "an auto_ptr containing an STL container may be used to prevent further modification of the container.". It used the following example:
auto_ptr<vector<ContainedType> > open_vec(new vector<ContainedType>);
open_vec->push_back(5);
open_vec->push_back(3);
// Transfers control, but now the vector cannot be...
In my code, I have the following:
ostream_iterator<double> doubleWriter(cout, " ~ ");
// ...
*doubleWriter = 1.1;
doubleWriter++;
*doubleWriter = 2.2;
*doubleWriter = 3.3; // shouldn't 2.2 be overwritten?
doubleWriter++;
*doubleWriter = 44.2;
cout << endl << endl;
I expected it to output this:
1.1 ~ 3.3 ~ 44.2 ~
Instead, the outp...
The following code does not work correctly. How should it be done correctly?
for (std::set<Color>::iterator i = myColorContainer.begin();
i!=myColorContainer.end();
++i)
{
if ( *i == Yellow)
{
DoSomeProccessing( *i );
myColorContainer.erase(i);
}
}
...
I hope the title is describing the problem, i'll change it if anyone has a better idea.
I'm storing information in a struct like this:
struct AnyStruct
{
AnyStruct() :
testInt(20),
testDouble(100.01),
testBool1(true),
testBool2(false),
testBool3(true),
testChar('x') {}
int testIn...
The first solution is:
std::vector<int> *vec = new std::vector<int>;
assert(vec != NULL);
// ...
delete vec;
An alternative is:
std::vector<int> v;
//...
vec.clear();
vec.swap(std::vector<int>(vec));
The second solution's a bit of a trick --- what's the "right" way to do it?
Update:
I'm aware that the destructor will be called on...
If a std::set or std::list contains a sequence of natural numbers (1, 2, 3..). would there be a function in standard library to find the missing number?
...
I remember hearing that the following code is not C++ compliant and was hoping someone with much more C++ legalese than me would be able to confirm or deny it.
std::vector<int*> intList;
intList.push_back(new int(2));
intList.push_back(new int(10));
intList.push_back(new int(17));
for(std::vector<int*>::iterator i = intList.begin(); i ...