std

Standard Library Source File

I am using GCC on cygwin, but I want to browse for source file of string.cpp from the standard library . I just want to read the source file for knowledge of the function I am using, but the problem is I can't find it anywhere. I only find the header files but not the source files. I assume it is store somewhere else, or maybe in another...

Does std::vector use the assignment operator of its value type to push_back elements?

If so, why? Why doesn't it use the copy constructor of the value type? I get the following error: /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/vector.tcc: In member functio n `ClassWithoutAss& ClassWithoutAss::operator=(const ClassWithoutAss&)': /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/vector.tcc:238: instantiate d f...

push_back of unique_ptr

What's wrong here? #include <memory> #include <vector> int main() { std::vector<std::unique_ptr<int>> vec; int x(1); std::unique_ptr<int> ptr2x(&x); vec.push_back(ptr2x); //This tiny command has a vicious error. return 0; } The error: $ g++ -std=gnu++0x main.cpp In file included from c:\mingw\bin\../lib/gcc/min...

Does std::move result in slicing?

For example, in unique_ptr<Derived> = new deriv; std::vector<unique_ptr<Base>>.push_back(std::move(deriv)); will deriv be sliced to type unique_ptr<Base>? ...

Slicing problem?

g++ -std=gnu++0x main.cpp In file included from main.cpp:6:0: CustArray.h: In constructor 'CustArray::CustArray()': CustArray.h:26:32: error: 'class Info' has no member named 'someInfo' make: *** [all] Error 1 /* * Info.h * */ #ifndef INFO_H_ #define INFO_H_ class Info { friend class CustArray; }; #endif /* INFO_H_ */ /* * ...

PHP Combining arrays with std class

Hello, This is what I want but cant figure out how to. $a is this array PHP Code: Array ( [0] => stdClass Object ( [id] => i1 [cat] => Test1 ) [1] => stdClass Object ( [id] => i2 [cat] => Test2 ) [2] => stdClass Object ( ...

C++ char * to string

Possible Duplicate: how to copy char * into a string and vice-versa I have to pass a value into a method that required a char * MyMethod(char * parameter) { // code } However, the parameter I need to feed it is currently a std::string. How do I convert the std::string to a char *? std::string myStringParameter = //what...

std::tr1::mem_fn return type

I want to put the result of this: std::tr1::mem_fn(&ClassA::method); Inside a variable, what is the type of this variable ? That will look something like this: MagicalType fun = std::tr1::mem_fn(&ClassA::method); Also, what is the result type of std::tr1::bind ? Thank you ! ...

Function that returns iterator from a map

I have a class with a map<K,V> variable which gets its value in the c'tor like so: class Foo { map<K,V> m; Foo (map<K,V>& newM) : m(newM) {} map<K,V>::iterator bar () { ... } } the function bar iterates through the map m, and return some an iterator to some element. I'm calling the function like this: std::map<K,V> map; /...

stringstream fails "streaming" negative values in unsigned types?

I'm having same issue in Ubuntu 10.04 using gcc4.4, the same code works fine on RH 5.5 using gcc4.1 #include <sstream> #include <iostream> int main(int argc, char** argv) { std::stringstream myStream; myStream << "-123"; unsigned int myUInt; myStream >> myUInt; if(myStream.fail()) { std::cout << "FAILED" << std::endl; ...

C++ Replace part of a string with another string

Is it possible in C++ to replace part of a string with another string. Basically, I would like to do this QString string("hello $name"); string.replace("$name", "Somename"); but I would like to use the Standard C++ libraries. ...

Filling std vector

Hello, I can't understand why does vector empty after it's filling. The code is: bool fillArray (vector<int> &array) { string temp; getline(cin, temp); if (temp == "-1") return false else return true; int res = atoi(temp.c_str()); array.push_back(res); } void showArray(const vector<int>...

Segfault in map

Hello, I can't understand why does this code fail with segfault: #include <cstdlib> #include <iostream> #include <map> #include <string> using namespace std; int main(int argc, char** argv) { map <string, string> temp; map <string, string>::iterator it; S string text = ""; string thatChange = ""; str...

Weird linker error with static std::map

Why do I get linker error when I try to compile this in Visual Studio 2008 #include <stdafx.h> #include <iostream> #include <map> #include <string> class MyClass { public: MyClass () { }; virtual ~MyClass() {}; static std::string niceString (std::map<int, int> mappp) { _myMap = mappp; return "nice string"; }; private: static std:...

data structure for storing array of strings in a memory

Hi everyone! I'm considering of data structure for storing a large array of strings in a memory. Strings will be inserted at the beginning of the programm and will not be added or deleted while programm is running. The crucial point is that search procedure should be as fast as it can be. Saving of memory is not important. I incline to s...

MSVC 10 + Luabind + std::vector == refuse to compile.

So, I have a code, that compiled on MSVC 9 and some previous (dunno how far back it goes...), GCC, MingW, GCC on Mac... But one line, does not compile on MSVC: class_< vector<unsigned int> >("LayerList") .def(constructor<>()) .def("GetCount", &vector<unsigned int>::size) .def("Get", &NumberGet) .def("Add", &vector<unsigned int>::push_...

std::sort and std::unique problem with a struct

The following code: #include <vector> #include <algorithm> struct myStructDim { int nId; int dwHeight; int dwWidth; }; void main() { ::std::vector<myStructDim> m_vec_dim; ::std::sort(m_vec_dim.begin(), m_vec_dim.end()); m_vec_dim.erase( ::std::unique(m_vec_dim.begin(), m_vec_dim.end())...

C++ STL list operator overloading for pairs (sorting according to first value, accessing with second value)

Hello I have some touble overloading operators for std::list. I store pairs in a list, consisting in an int value and a position array : typedef std::pair< int, std::vector<int,3> > pointPairType; typedef std::list< pointPairType > pointListQueueType; pointListQueueType pointsQueue; // adding some points to the list And I wou...

EXEC_BAD_ADDRESS

Hi, maybe this is the continuation of this thread, The program compiles without errors or warnings but when I run it, and the handler function is called, I get EXEC_BAD_ADDRESS void MainController::show_color_trackbars(int *h, int *s, int *v){ String winName = "HSV Trackbars"; namedWindow(winName, CV_WINDOW_AUTOSIZE); std:...

Alternative to stdext::hash_map for performance reasons

Hi All, I'm working on a high performance application where all calls must be justified. I have a map that is used once in the beginning of each transaction to do a lookup that I would like to improve upon. The map is loaded at startup and does not change after that. The key in the map below is an std::string but it can it changed ...