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
20
votes
4 answers

Alternative implementations of Haskell's standard library type classes

I've seen many people complaining about some of the type classes from the standard library saying things like "Monad should require Functor" or even "Monad should require Applicative", "Applicative should require Pointed", "Num shouldn't require…
Rafael S. Calsaverini
  • 13,582
  • 19
  • 75
  • 132
20
votes
5 answers

Where are the functions in the C standard library defined?

I'm not interested in the source code, I want to know how the C compiler (GCC) actually finds the functions. As in, when the preprocessor sees that I've included stdio.h, where does it look to find the files that define the function bodies? Edit I…
Tyler
  • 2,579
  • 2
  • 22
  • 32
19
votes
1 answer

Get Unix time in Python

In Python, I want to get the current Unix timestamp and then store the value for the long term and be handled by non-Python systems. (I am not merely trying to compute the difference between two timestamps within the same program run.) Calling the…
Nayuki
  • 17,911
  • 6
  • 53
  • 80
19
votes
1 answer

What new Unicode functions are there in C++0x?

It has been mentioned in several sources that C++0x will include better language-level support for Unicode(including types and literals). If the language is going to add these new features, it's only natural to assume that the standard library will…
luiscubal
  • 24,773
  • 9
  • 57
  • 83
19
votes
9 answers

Does C or C++ have a standard regex library?

Does it? If yes, where can I get the documentation for it... if not, then which would be the best alternative?
aviraldg
  • 9,531
  • 6
  • 41
  • 56
18
votes
7 answers

trim is not part of the standard c/c++ library?

Is it me or are there no standard trim functions in the c or c++ library? is there any single function that acts as a trim? If not can anyone tell me Why trim is not part of the standard library? (i know trim is in boost) My trim code is std::string…
user34537
18
votes
1 answer

Why are C++ iterators required to return a reference?

I'm implementing an iterator that iterates over the results of a generator function rather than over a data structure in memory such as a vector or map. Reading through the final working draft for C++17 §27.2.3, the return type of the dereference…
18
votes
2 answers

C: Differences between strchr() and index()

I am doing something in C which requires use of the strings (as most programs do). Looking in the manpages, I found, at string(3): SYNOPSIS #include char * index(const char *s, int c) (...) #include char * strchr(const…
ssice
  • 3,564
  • 1
  • 26
  • 44
18
votes
2 answers

Why doesn't Clang come with standard library headers?

I downloaded Clang 3.6.2 from this website and am trying to set it up with Code::Blocks under Windows. Unfortunately, it fails to compile a simple "hello world" program on the grounds that it doesn't know where iostream is. Looking through the…
Therhang
  • 825
  • 1
  • 9
  • 15
18
votes
1 answer

Possibility of COW std::string implementation in C++11

Today I passed by this SO question: Legality of COW std::string implementation in C++11 The most voted answer (35 upvotes) for that question says: It's not allowed, because as per the standard 21.4.1 p6, invalidation of iterators/references is…
goodbyeera
  • 3,169
  • 2
  • 18
  • 39
17
votes
3 answers

Do Standard Library (STL) Containers support a form of nothrow allocation?

The new operator (or for PODs, malloc/calloc) support a simple and efficient form of failing when allocating large chunks of memory. Say we have this: const size_t sz = GetPotentiallyLargeBufferSize(); // 1M - 1000M T* p = new (nothrow)…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
17
votes
1 answer

Best way to convert fractions.Fraction to decimal.Decimal?

In Python, the fractions.Fraction and decimal.Decimal standard library classes exist to help keep arithmetic with rational numbers precise. For the unfamiliar, an example of where it helps: >>> 1 / 10 * 3 0.30000000000000004 >>> decimal.Decimal('1')…
Dan Passaro
  • 4,211
  • 2
  • 29
  • 33
17
votes
1 answer

Swift's standard library and name collision

I know that Swift doesn't use namespaces, but that names are defined within each module. First of all, I don't understand very well how this avoids name collisions -feel free to elaborate. Nevertheless, my main question is: Let's say I want a tree…
George
  • 1,235
  • 10
  • 23
17
votes
2 answers

How to access a standard-library module in Python when there is a local module with the same name?

How can a standard-library module (say math) be accessed when a file prog.py is placed in the same directory as a local module with the same name (math.py)? I'm asking this question because I would like to create a package uncertainties that one can…
Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
17
votes
4 answers

SBCL standard library documentation?

I want to learn and use SBCL because of its ease of learning and speed. (I've been playing with Lisp 3 years ago, and now am refreshing it.) But how can I learn what's included in the standard library, so that I don't re-implement things? After…
culebrón
  • 34,265
  • 20
  • 72
  • 110