Questions tagged [std]

The C++ Standard Library, and its namespace. Use in conjunction with [c++].

From Wikipedia

The C++ Standard Library provides several generic containers, functions to utilise and manipulate these containers, function objects, generic strings and streams (including interactive and file I/O).

http://en.wikipedia.org/wiki/C++_Standard_Library

The concept of using namespaces

http://en.wikipedia.org/wiki/Namespace_(computer_science)

Also see

4970 questions
3
votes
5 answers

how to return a null iterator in c++?

I am writing a wrapper class which looks like this: class Wrapper{ private: std::list men; std::list woman; /** some bizzar logics **/ public: std::list::iterator getMeTheNextOne(){}; } The…
James Bond
  • 7,533
  • 19
  • 50
  • 64
3
votes
1 answer

Why different `this` address in using multiple inheritance

In C++, it is small sample code that using std::enable_shared_from_this and inheritance. The p in this code, call a member function fb and fa. The p is the same object, but called fa and fb take a different this address. Why take a different…
Usagi Ito
  • 483
  • 7
  • 16
3
votes
1 answer

Is std::deque really thread safe at all?

I know what the books say about std::deque being moderately thread safe but my experience is proving otherwise. I'm using VS 2010. There are at least two threads (could be N threads but adding threads only makes the problem happen sooner) each…
brimaa
  • 169
  • 3
  • 11
3
votes
4 answers

Vector is not a member of std with everything included

I'm getting a very strange error and something I've never experienced before, I'm trying to initialize a vector at declaration like so: vector myVector (5,4,3,4); It gives me an error saying that it cannot find a call matching that…
Scholar
  • 293
  • 3
  • 8
  • 16
3
votes
2 answers

make 'const' work with the result of type traits

int main(int argc, char* argv[]) { const int i = 10; using Type = typename std::conditional::type; const Type r = i; // It seems this 'const' does not have any effect. std::cout << r << std::endl; } The above code cannot…
mumu
  • 197
  • 7
3
votes
4 answers

C++ Parse XML Using STD

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. 23432 What I am trying to do…
different
  • 31
  • 1
  • 1
  • 2
3
votes
3 answers

Are there any 100% C++11 compatible implementations of std?

Are there any open-source 100% C++11 compatible(*) implementations of standard C++ library? (*) An implementation which is proven to match the standard completely or an implementation which has no known defects.
Kolyunya
  • 5,973
  • 7
  • 46
  • 81
3
votes
4 answers

sorting std vector of strings without using default algorithm

I have an std::vector of std::strings, each of which is a filename. Suppose filenames are of the format some_name_n.xyz. The problem is that some_name_10.xyz is less than some_name_2.xyz. The files are produced by some other process. What is the…
Bob
  • 10,741
  • 27
  • 89
  • 143
3
votes
2 answers

C++11 Thread Queue

I would like to be able to launch a whole bunch of threads: futures_que< std::future< ret_value > > fq; for ( auto a: some_very_large_container ) fq.push_back( std::async( std::launch::async, some_computationally_expensive_function,…
Andrew Spott
  • 3,457
  • 8
  • 33
  • 59
3
votes
1 answer

std::unordered_map: Asymptotic {search,insert,remove} performance in the size of the key, and by data type

I am using an std::unordered_map in C++11. I am deciding between string keys and a compound data type (like two longs put together in a struct to hold a UUID). Is there an easy way to determine the performance characteristics of lookups, inserts,…
skyw
  • 349
  • 4
  • 15
3
votes
2 answers

insert a std::initializer_list into std::map

I have a method like this: std::map container; void myMap(std::initializer_list> input) { // insert 'input' into map... } I can call that method like this: myMap({ {"foo", 1} }); How I can…
SH.0x90
  • 532
  • 2
  • 7
  • 19
3
votes
3 answers

Accessing data inside std::vector container

I have three std::vector. typedef std::pair< double,double > A; typedef std::vector< A > B; typedef std::vector< B > C; I know how to access the element inside B like B b; b.at(0).first; b.at(0).second; And C c; How can I access the element of b…
batuman
  • 7,066
  • 26
  • 107
  • 229
3
votes
1 answer

VS2012 bind2nd is not a member of std

I had some code already working on vs2008 and I am trying to port it to vs2012. On this source code I am using the function bind2nd specified and using std::bind2nd and everything works perfectly. When I compile the same code with vs2012 I get an…
ruba
  • 120
  • 2
  • 9
3
votes
1 answer

mem_fun_ref: unresolved overloaded function type

The following code won't compile because of "error: no matching function for call to ‘mem_fun_ref()’" (gcc version 4.4.6). #include #include #include #include #include using namespace std; class…
BlakBat
  • 1,835
  • 5
  • 17
  • 21
3
votes
2 answers

Adding new item and searching with time key in a 3 element map C++

I want to create a map with a high resolution timestamp key and two other items. So I thought something like that: std::map> someContainer; //(time_t will be replaced) 1) I need a timestamp type which is nanosecond…
Vecihi
  • 261
  • 4
  • 12