Questions tagged [standard-library]

The standard library contains core utilities provided by all implementations of the language.

The standard library contains core utilities provided by all implementations of the language.

The size and scope of the standard library varies between languages, some provide only a few basic components for such things as string handling and I/O, whereas others provide higher-level tools for a wide variety of tasks such as XML processing, networking and database access.

For questions about specific languages' standard libraries use this tag in conjunction with the tag for the language, or use the indicated tags for these languages:

677 questions
27
votes
3 answers

Where can I find all the exception guarantees for the Standard Containers and Algorithms?

Yes, I've looked at the C++ standards that I could find (or the drafts), but I'm not finding any comprehensive of the exception guarantees given by STL containers. All I can find are occasional sections with incomplete descriptions on some of the…
user541686
  • 205,094
  • 128
  • 528
  • 886
26
votes
2 answers

std::ops::Add or core::ops::Add?

These two traits (std::ops::Add, core::ops::Add) provide the same functionality, and they both use the same example (both utilize std::ops::Add). Their set of implementors differ somewhat. Should one default to using std::ops::Add? Why do both, as…
Filip Allberg
  • 3,941
  • 3
  • 20
  • 37
25
votes
3 answers

Strange bug in usage of abs() I encountered recently

I have C++/C mixed code which I build on a) Visual C++ 2010 Express(Free version) on Win-7 x32. b) Cygwin/Gcc environment installed on a Windows-7 Home premium edition x32. The gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) c) Ubuntu…
goldenmean
  • 18,376
  • 54
  • 154
  • 211
25
votes
3 answers

Why does the reverse() function in the Swift standard library return ReverseRandomAccessCollection?

Now that I've learned Swift (to a reasonable level) I'm trying to get to grips with the standard library, but in truth it's mainly ελληνικά to me! So a specific question: I have an array of strings and I can call reverse() on it. let arr =…
Brynjar
  • 1,252
  • 1
  • 11
  • 24
25
votes
5 answers

Why doesn't the .Net framework have a priority queue class?

There are some threads on Stack Overflow dealing with implementing priority queues in .Net and C#. My issue is of a more basic nature: Why isn't there a priority queue out of the box in the .Net framework? Even the C++ Standard Library has one.
25
votes
5 answers

Rationale for C++'s std map insert semantics?

I'm a little bit confused by std::map::insert's semantics. I mean, I'm not complaining - the standard is the standard and the API is the way it is. Still, insert will the insertion operation checks for each element inserted whether another…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
24
votes
6 answers

What language are the C and C++ standard libraries written in?

C and C++ by themselves can't actually do anything, they need the libraries to work. So how were the libraries created? Assembly language?
alecwhardy
  • 2,698
  • 6
  • 27
  • 33
24
votes
2 answers

Is there a way to check if an istream was opened in binary mode?

I'm using an istream which could be stringstream, ifstream or a user-defined stream type and I need to know if, in the case of an ifstream, it was not opened in binary mode (so I can throw an exception). I have tried the following method: if…
Ferruccio
  • 98,941
  • 38
  • 226
  • 299
23
votes
1 answer

Are names in the C++ Standard Library meant to be in British English or American English?

After a quick search in draft N4296, I could not find any example of a name in the C++ Standard Library for which two possible spellings exists (BrE vs. AmE). While this may even be intentional, I can imagine that at some point, if a graphics…
Andy Prowl
  • 124,023
  • 23
  • 387
  • 451
23
votes
1 answer

Why does OpenURI treat files under 10kb in size as StringIO?

I fetch images with open-uri from a remote website and persist them on my local server within my Ruby on Rails application. Most of the images were shown without a problem, but some images just didn't show up. After a very long debugging-session I…
klaffenboeck
  • 6,297
  • 3
  • 23
  • 33
22
votes
8 answers

Real world use-case for the `at()` indexing function in the C++ std library?

C++'s container vector, deque, ... provide the at(index) accessor function in addition to operator[index] to access container elements. The difference between this member function and member operator function operator[] is that deque::at…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
22
votes
4 answers

Changing Java PriorityQueue to a Max PQ

The Priority Queue implementation in the Java standard library appears to be a min Priority Queue which I found somewhat confusing. In order to turn it into a max one I created a custom comparator object. Comparator cmp = new…
Chris
  • 631
  • 1
  • 9
  • 17
22
votes
2 answers

Is there a combination of takeWhile,dropWhile in Scala?

In Scala, I want to split a string at a specific character like so: scala> val s = "abba.aadd" s: String = abba.aadd scala> val (beforeDot,afterDot) = (s takeWhile (_!='.'), s dropWhile (_!='.')) beforeDot: String = abba afterDot: String =…
Felix
  • 8,385
  • 10
  • 40
  • 59
21
votes
5 answers

So where can I find the best online C++ Standard Library reference?

You know, with comments and examples and stuff. Need a quick reference for when coding.
navand
  • 1,379
  • 1
  • 16
  • 20
21
votes
4 answers

Why is numCapabilities a pure function?

In the concurrency library GHC.Conc there is a function called numCapabilities. Its type is numCapabilities :: Int and it actually returns some number you passed by the command line flag (e.g. 5 if the options are +RTS -N 5). However, getArgs…
helami
  • 2,099
  • 2
  • 14
  • 17