On Saturday, 3 November 2012 at 18:38:14 UTC, Too Embarrassed To
Say wrote:
The std.container starts off with container primitives. Does
this mean that all containers should support all these
primitives? Because I could never get c.length to work for a
simple SList.
That is a complete list of all possible primitives that can occur
in the interface of a std.container. However not every container
defines every primitive. SList for example does not define
length, because length is required (by convention) to be O(1),
which is impossible with the current SList implementation.
Are there formal definitions for U and Stuff like in (U)(U[]
values...) and (string op, Stuff)(Stuff stuff);
No really, these are template parameters. U needs to be implicit
convertible to T for an SList!T and Stuff needs to be an
InputRange of U. Which you can only know if you read the source
:-)
struct SList(T); // Implements a simple and fast
singly-linked list.
Since SList is a structure and in the excellent book by
Andrei[A..u], he says for structure constructors (7.1.3.1)
“…the compiler always defines the no-arguments
constructor”.
This being the case shouldn’t one of the following compile?
SList(int) s1;
SList() s2;
SList s3;
auto s4 = SList;
auto s5 = SList();
auto s6 = SList(int);
You need an ! before the template parameter.
SList!int s1;
SList!(TypeTuple!(int, long)) s2;
Note that the container are reference types.