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

C++11 Thread waiting behaviour: std::this_thread::yield() vs. std::this_thread::sleep_for( std::chrono::milliseconds(1) )

I was told when writing Microsoft specific C++ code that writing Sleep(1) is much better than Sleep(0) for spinlocking, due to the fact that Sleep(0) will use more of the CPU time, moreover, it only yields if there is another equal-priority thread…
Thomas Russell
  • 5,870
  • 4
  • 33
  • 68
45
votes
2 answers

Is it legal to pass a non-null-terminated string to strncmp in C?

I have an array of 16 bytes that holds the name of an executable's segment. char segname[16]; If the segment name length is less than 16 bytes, then the rest is padded with null bytes. Otherwise, there is no terminating null byte. I want to compare…
Bilow
  • 2,194
  • 1
  • 19
  • 34
41
votes
1 answer

What are the differences amongst Python's "__get*__" and "_del*__" methods?

I just started learning Python a few months ago, and I'm trying to understand the differences between the different __get*__ methods: __get__ __getattr__ __getattribute__ __getitem___ And their __del*__…
Zearin
  • 1,474
  • 2
  • 17
  • 36
41
votes
3 answers

Why do iterators need to be default-constructible

Iterators of the categories forward, bidirectional, and random access need to be default-constructible. Why is this, and why do input and output operators not have to be default-constructible?
sbi
  • 219,715
  • 46
  • 258
  • 445
39
votes
2 answers

When should I use std::bind?

Every time I need to use std::bind, I end up using a lambda instead. So when should I use std::bind? I just finished removing it from one codebase, and I found that lambdas were always simpler and clearer than std::bind. Isn't std::bind completely…
gnzlbg
  • 7,135
  • 5
  • 53
  • 106
37
votes
3 answers

Why is this cast to bool required?

template inline InputIterator find_if(InputIterator first, InputIterator last, Predicate pred, input_iterator_tag) { while (first != last && !bool(pred(*first))) ++first; return…
qdii
  • 12,505
  • 10
  • 59
  • 116
37
votes
3 answers

numeric_limits lowest and min member functions

numeric_limits::min(); numeric_limits::lowest(); What is the different between the value returned by both functions?
Muhammad
  • 1,598
  • 3
  • 19
  • 31
33
votes
2 answers

Is there a std::noncopyable (or equivalent)?

There's a boost::noncopyable and I have my own noncopyable class in my library. Is there a std::noncopyable or equivalent knocking around in the latest C++ standard? It's a small thing but deriving from such a class makes the intention much…
Robinson
  • 9,666
  • 16
  • 71
  • 115
32
votes
1 answer

Compile-time reflection in C++1z?

There is a study group in the C++ standardization committee to provide compile-time reflection in C++1z or after. I would like to know what is exactly the purpose and how powerful the expected tools will be? For example will it be possible to name…
Vincent
  • 57,703
  • 61
  • 205
  • 388
30
votes
10 answers

Boost dependency for a C++ open source project?

Boost is meant to be the standard non-standard C++ library that every C++ user can use. Is it reasonable to assume it's available for an open source C++ project, or is it a large dependency too far?
dajobe
  • 4,938
  • 35
  • 41
30
votes
2 answers

Why does str.split not take keyword arguments?

I came across this - in my view - strange behaviour: "a b c".split(maxsplit=1) TypeError: split() takes no keyword arguments Why does str.split() not take keyword arguments, even though it would make sense? I found this behavior both in Python2 and…
Peter Smit
  • 27,696
  • 33
  • 111
  • 170
29
votes
4 answers

Which standard library to use in Kotlin

In Kotlin, when working with the JVM, it seems there is multiple choices for standard library, namely kotlin-stdlib, kotlin-stdlib-jdk7 and kotlin-stdlib-jdk8. I cannot, however, find anything telling me the difference between these. The only…
beruic
  • 5,517
  • 3
  • 35
  • 59
29
votes
7 answers

Where to find algorithms for standard math functions?

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
29
votes
1 answer

Why were Haskell 98's standard classes made inferior to Haskell 1.3's?

Before Haskell 98, there were Haskell 1.0 through 1.4. It's pretty interesting to see the development throughout the years, as features were added to the earliest versions of standardized Haskell. For instance, the do-notation was first standardized…
user824425
29
votes
5 answers

How can pointers be totally ordered?

Pointers in C++ may in general only be compared for equality. By contrast, less-than comparison is only allowed for two pointers that point to subobjects of the same complete object (e.g. array elements). So given T * p, * q, it is illegal in…
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084
1 2
3
45 46