stdlib

Why is the endptr parameter to strtof and strtod a pointer to a non-const char pointer?

The standard C library functions strtof and strtod have the following signatures: float strtof(const char *str, char **endptr); double strtod(const char *str, char **endptr); They each decompose the input string, str, into three parts: An initial, possibly-empty, sequence of whitespace A "subject sequence" of characters that repres...

C++0x Smart Pointer Comparisons: Inconsistent, what's the rationale?

In C++0x (n3126), smart pointers can be compared, both relationally and for equality. However, the way this is done seems inconsistent to me. For example, shared_ptr defines operator< be equivalent to: template <typename T, typename U> bool operator<(const shared_ptr<T>& a, const shared_ptr<T>& b) { return std::less<void*>()(a.get(...

Python generator that groups another iterable into groups of N.

I'm looking for a function that takes an iterable i and a size n and yields tuples of length n that are sequential values from i: x = [1,2,3,4,5,6,7,8,9,0] [z for z in TheFunc(x,3)] gives [(1,2,3),(4,5,6),(7,8,9),(0)] Does such a function exist in the standard library? If it exists as part of the standard library, I can't seem to ...

How is std::tuple implemented?

I'd like to know how are tuple implemented in standard library for C++0x. I tried to read description in libstdc++ manual and then read template listing, but it's really hard to understand how it works, especially when reading code. Can someone explain me in few sentences the idea of tuple implementation? I want to know this, because I ...