Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 15 additions & 28 deletions cpptod.dd
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,14 @@ corresponding task in D.)

See also: <a href="ctod.html">Programming in D for C Programmers</a>

$(UL
$(LI $(RELATIVE_LINK2 constructors, Defining Constructors))
$(LI $(RELATIVE_LINK2 baseclass, Base class initialization))
$(LI $(RELATIVE_LINK2 structcmp, Comparing structs))
$(LI $(RELATIVE_LINK2 typedefs, Creating a new typedef'd type))
$(LI $(RELATIVE_LINK2 friends, Friends))
$(LI $(RELATIVE_LINK2 operatoroverloading, Operator overloading))
$(LI $(RELATIVE_LINK2 usingdeclaration, Namespace using declarations))
$(LI $(RELATIVE_LINK2 raii, RAII (Resource Acquisition Is Initialization)))
$(LI $(RELATIVE_LINK2 properties, Properties))
$(LI $(RELATIVE_LINK2 recursivetemplates, Recursive Templates))
$(LI $(RELATIVE_LINK2 metatemplates, Meta Templates))
$(LI $(RELATIVE_LINK2 typetraits, Type Traits))
$(LI $(RELATIVE_LINK2 interfaces, Interfaces))
$(LI $(RELATIVE_LINK2 references, References in D))
$(HEADERNAV_TOC)

)


<hr>$(COMMENT -------------------------------------------- )

$(H3 <a name="constructors">Defining constructors</a>)
$(H2 $(LNAME2 constructors, Defining constructors))

$(H4 The C++ Way)

Expand All @@ -59,7 +46,7 @@ class Foo
which reflects how they are used in D.

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="baseclass">Base class initialization</a>)
$(H2 $(LNAME2 baseclass, Base class initialization))

$(H4 The C++ Way)

Expand Down Expand Up @@ -128,7 +115,7 @@ class A
------

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="structcmp">Comparing structs</a>)
$(H2 $(LNAME2 structcmp, Comparing structs))

$(H4 The C++ Way)

Expand Down Expand Up @@ -191,7 +178,7 @@ if (x == y)
------

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="typedefs">Creating a new typedef'd type</a>)
$(H2 $(LNAME2 typedefs, Creating a new typedef'd type))

$(H4 The C++ Way)

Expand Down Expand Up @@ -258,7 +245,7 @@ if (h != Handle.init)
as a value of the underlying type.

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="friends">Friends</a>)
$(H2 $(LNAME2 friends, Friends))

$(H4 The C++ Way)

Expand Down Expand Up @@ -329,7 +316,7 @@ int abc(A p) { return p.a; }
accessing the members.

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="operatoroverloading">Operator overloading</a>)
$(H2 $(LNAME2 operatoroverloading, Operator overloading))

$(H4 The C++ Way)

Expand Down Expand Up @@ -378,7 +365,7 @@ struct A
the same effect.)

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="usingdeclaration">Namespace using declarations</a>)
$(H2 $(LNAME2 usingdeclaration, Namespace using declarations))

$(H4 The C++ Way)

Expand Down Expand Up @@ -413,7 +400,7 @@ alias x = foo.x;
template members, refer to nested class types, etc.

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="raii">RAII (Resource Acquisition Is Initialization)</a>)
$(H2 $(LNAME2 raii, RAII (Resource Acquisition Is Initialization)))

$(H4 The C++ Way)

Expand Down Expand Up @@ -478,7 +465,7 @@ scope.)


<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="properties">Properties</a>)
$(H2 $(LNAME2 properties, Properties))

$(H4 The C++ Way)

Expand Down Expand Up @@ -545,7 +532,7 @@ int x = a.property;
data fields, behave syntactically as if they did.

<hr>$(COMMENT -------------------------------------------- )
$(H3 <a name="recursivetemplates">Recursive Templates</a>)
$(H2 $(LNAME2 recursivetemplates, Recursive Templates))

$(H4 The C++ Way)

Expand Down Expand Up @@ -606,7 +593,7 @@ enum factorial(int n : 1) = 1;

<hr>$(COMMENT -------------------------------------------- )

$(H3 <a name="metatemplates">Meta Templates</a>)
$(H2 $(LNAME2 metatemplates, Meta Templates))

The problem: create a typedef for a signed integral type that is at
least $(I nbits) in size.
Expand Down Expand Up @@ -758,7 +745,7 @@ int main()

<hr>$(COMMENT -------------------------------------------- )

$(H3 <a name="typetraits">Type Traits</a>)
$(H2 $(LNAME2 typetraits, Type Traits))

Type traits are another term for being able to find out
properties of a type at compile time.
Expand Down Expand Up @@ -833,7 +820,7 @@ void test()

$(HR)

$(H3 $(LNAME2 interfaces, Interfaces))
$(H2 $(LNAME2 interfaces, Interfaces))


Interfaces in C++ are used to describe the behaviour or capabilities of any class
Expand Down
16 changes: 9 additions & 7 deletions ctarguments.dd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Ddoc

$(D_S Compile-time Argument Lists,

$(HEADERNAV_TOC)

$(P Compile-time lists is an important metaprogramming concept that comes naturally
from D support for $(LINK2 variadic-function-templates.html, variadic templates). They
allow a programmer to operate on types, symbols and expressions enabling the ability to define
Expand Down Expand Up @@ -67,16 +69,16 @@ $(D_S Compile-time Argument Lists,
pragma(msg, AliasSeq!("aaa", 0, double)[2]);
---

$(H3 Available operations)
$(H2 $(LNAME2 available-operations, Available operations))

$(H4 Checking the length)
$(H3 $(LNAME2 checking-length, Checking the length))

---
import std.meta;
static assert (AliasSeq!(1, 2, 3, 4).length == 4);
---

$(H4 Indexing and slicing)
$(H3 $(LNAME2 indexing-slicing, Indexing and slicing))

$(P Indexes must be known at compile-time)

Expand All @@ -88,7 +90,7 @@ $(H3 Available operations)
static assert (SubNumbers[0] == 2);
---

$(H4 Assignment)
$(H3 $(LNAME2 assignment, Assignment))

$(P Works only if the list element is a symbol that refers to a mutable variable)

Expand All @@ -105,7 +107,7 @@ $(H3 Available operations)
}
---

$(H4 Loops)
$(H3 $(LNAME2 loops, Loops))

$(P D's $(LINK2 spec/statement.html#ForeachStatement, foreach statement) has special
semantics when iterating over compile-time lists. It repeats the body of the loop
Expand Down Expand Up @@ -135,7 +137,7 @@ $(H3 Available operations)
*/
---

$(H3 Auto-expansion)
$(H2 $(LNAME2 auto-expansion, Auto-expansion))

$(P One less obvious property of compile-time argument lists is that when used
as an argument to a function or template, they are automatically treated as a list
Expand All @@ -159,7 +161,7 @@ $(H3 Auto-expansion)
the language semantics for variadic lists, and thus also preserved by `AliasSeq`.
)

$(H3 Homogenous lists)
$(H2 $(LNAME2 homogenous-lists, Homogenous lists))

$(P An `AliasSeq` that consist of only type or expression (value) elements are
commonly called "type lists" or "expression lists" respectively. The concept of
Expand Down
Loading