Standard Library Containers with additional optional template parameters?

I found the following issue report, which says There is no ambiguity; the standard is clear as written. Library implementors are not permitted to add template parameters to standard library classes. This does not fall under the “as if” rule, so it would be permitted only if the standard gave explicit license for implementors to … Read more

Is a C++ preprocessor identical to a C preprocessor?

The C++03 preprocessor is (at least intended to be) similar to the C preprocessor before C99. Although the wording and paragraph numbers are slightly different, the only technical differences I’m aware of between the two are that the C++ preprocessor handles digraphs (two-letter alternative tokens) and universal character names, which are not present in C. … Read more

Why an unnamed namespace is a “superior” alternative to static? [duplicate]

As you’ve mentioned, namespace works for anything, not just for functions and objects. As Greg has pointed out, static means too many things already. Namespaces provide a uniform and consistent way of controlling visibility at the global scope. You don’t have to use different tools for the same thing. When using an anonymous namespace, the … Read more

std::vector and contiguous memory of multidimensional arrays

The standard does require the memory of an std::vector to be contiguous. On the other hand, if you write something like: std::vector<std::vector<double> > v; the global memory (all of the v[i][j]) will not be contiguous. The usual way of creating 2D arrays is to use a single std::vector<double> v; and calculate the indexes, exactly as … Read more

Declare main prototype

C language standard, draft n1256: 5.1.2.2.1 Program startup 1 The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters: int main(void) { /* … */ } or with two parameters (referred to here as … Read more

tech