1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
The tt(Math:Utility) partition is the most basic of the two tt(Math)
partitions. It does not depend on features of either the tt(Math) module or
the tt(Math:Add) partition. Since it em(does) use the tt(size_t) type, it
specifies tt(export import <cstddef>). Here, because of its tt(export)
specification, the definitions in tt(cstddef) are also available when
tt(Utility) is imported, and since the tt(Math) module itself exports
tt(:Utility) also to software importing tt(Math).
As tt(Utility) is a tt(Math) partition its partition interface unit starts by
specifing this:
verb( export module Math:Utility;)
The colon indicates that this is not a plain module but a partition (note
that the first line em(must) start by specifying tt(export)). It contains
em(only) non-exported components, but as it's a partition of a module, all the
partition's components are fully available to its module and its sibling
partitions. Its tt(class Utility) has two simple members, both very simple,
never changing one-liners. Because of that they're implemented in-line. Here's
the tt(Utility) partition interface unit:
verbinsert(-as4 examples/partition/math/utility/modutility.cc)
Defining members inline is not required, but is an option. For example, its
constructor could very well also have been defined inline, but (for
illustration purposes) is defined in a separate source file. As tt(Utility's)
constructor is a partition source file it starts by specifying its module
(tt(Math)), followed by importing the partition component (tt(:Utility)) which
is defined in this source file:
verbinsert(-as4 examples/partition/math/utility/utility1.cc)
|