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
1 answer

"Converting" from int[] to std::array at fread?

I was wondering and have not found any advice, on how to convert a C-style integer array to a new std::array from C++11 I love the std::array and use it a lot, anyhow if I read in data from binary files, I work around to copy the values. Isn't…
Stefan
  • 2,603
  • 2
  • 33
  • 62
3
votes
2 answers

php objects: property Object Vs stdClass Object - which one is better?

Sometimes I use __get or stdClass to convert arrays to object. But I can't decide I should stick to. I wonder which one is better and faster, any ideas? class property { public function __get($name) { return (isset($this->$name)) ?…
Run
  • 54,938
  • 169
  • 450
  • 748
3
votes
1 answer

using rdbuf()->sputn(...) vs operator<<

I am looking through some legacy code and found that temporary std::string objects are being used liberally throughout the code to convert const char* to force the use of : inline std::ostream & operator << (std::ostream & s, const std::string &…
Caribou
  • 2,070
  • 13
  • 29
3
votes
1 answer

Questionable definition of common_type

in book "The Cpp standard library", 2nd edition, by Nicolai M. Josuttis, says (5.4, p.125) that definition of struct common type is following: template struct common_type { typedef decltype(true ? declval() :…
smallB
  • 16,662
  • 33
  • 107
  • 151
3
votes
1 answer

C++ regex match content inside curly braces

Suppose I would like to do extract the contents of matching curly braces using C++11 regex. So, for example, {foo} would match successfully and I could the use the match_result to extract the contents. It seems simple, but the following code does…
Alan Turing
  • 12,223
  • 16
  • 74
  • 116
3
votes
3 answers

How i can return a std::map containing the differences of two maps in c++?

i have two maps and i need to find the differences and create a new map that only has the differences. Not sure how to do this. I tried using set_difference but don't really understand how it works. Any help would be appreciated. thanks // header…
Bullsfan127
  • 285
  • 6
  • 18
3
votes
1 answer

Strange enum syntax in std library header

I was using a stringstream recently stringstream ss (stringstream::in | stringstream::out); and I decided to look at the declaration of in and out and I am somewhat confused with how they are declared. Would someone be able to clarify A. why they…
TomP89
  • 1,420
  • 3
  • 11
  • 29
3
votes
1 answer

Getters/Setters with std::vector<>.push_back(...)

For some reason this doesn't work. It compiles file, but no items are added to this vector when using a getter. E.G. class class_name { public: inline std::vector get_numbers() { return m_numbers; } private: …
user1043761
  • 696
  • 6
  • 22
3
votes
2 answers

Disambiguating std::isalpha() in C++

So I am currently writing a part of a program that takes user text input. I want to ignore all input characters that are not alphabetic, and so I figured std::isalpha() would be a good way to do this. Unfortunately, as far as I know there are two…
GarrickW
  • 2,181
  • 5
  • 31
  • 38
3
votes
4 answers

How to know when a vector’s internal array is reallocated?

I have a std::vector containing a lot of elements. As the vector is huge, I store pointers to some specific elements in another vector, to be able to access them faster. But as the vector grows, sometimes its internal container gets reallocated,…
qdii
  • 12,505
  • 10
  • 59
  • 116
3
votes
0 answers

Using large ostream tellp() function with large files when position > ULONG_MAX

I'm trying to store offsets of a file pointing to different positions on it. Using tellp() function, I can know the actual position in the file, that is, an integer. The problem comes when this number reaches 4.294.967.295. Overflow appears and…
auroras
  • 51
  • 3
3
votes
1 answer

c++11 std::thread compiles with function, but not class

I am using g++ 4.7 with the c++11 flag. In this demo: #include #include class do_work { public: void operator()() { std::cout << "Doing work..." << std::endl; } }; void foo() { } int main() { // Does not work …
David Doria
  • 9,873
  • 17
  • 85
  • 147
3
votes
3 answers

"inverse" associative container?

does there exist a kind of "inverse" associative container in the stl or in general? For instance I'd like to have a container where the same element is shared by a set of keys. Let's say my key is an int, then I would have for…
lezebulon
  • 7,607
  • 11
  • 42
  • 73
3
votes
2 answers

std::ostream::operator<< not defined for std::string?

I have stumbled upon an error for which I cannot grasp the reason. I think it basically gets down to this error: error: no matching function for call to ‘std::basic_ostream::operator<<(const std::basic_string&)’ I looked into…
luk32
  • 15,812
  • 38
  • 62
3
votes
1 answer

Performance guarantees for now() call of standard chrono clocks?

Are there any performance guarantees in the standard required for the implement of the now() static functions of each clock in std::chrono? In n3337 I read that ( 20.11.3 Clock requirements [time.clock.req] ): 3 [ Note: The relative difference in…
Klaim
  • 67,274
  • 36
  • 133
  • 188
1 2 3
99
100