mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
24 lines
1.1 KiB
Text
24 lines
1.1 KiB
Text
Finally we reach the class template tt(Semantic), publicly derived from
|
|
tt(SemBase). This class template only requires one tt(Tag) non-type parameter,
|
|
defining the kind of data that can be handled by objects of the class.
|
|
|
|
Like tt(SemBase) the class tt(Semantic) is extremely light-weight. Only
|
|
initialization and a conversion operator to the encapsulated data member must
|
|
be supported.
|
|
|
|
tt(Semantic) defines its data member as mutable, which is fine as the class
|
|
itself doesn't manipulate its data, and proper access to the data is
|
|
guaranteed by its tt(operator ReturnType() const) conversion
|
|
operator. tt(ReturnType), of course, is obtained through the tt(Trait) trait
|
|
class template.
|
|
|
|
Here is the class's interface and member definitions:
|
|
verbinclude(//SEMANTIC poly2/sembase/sembase.h)
|
|
|
|
To access the information stored in a semantic value class the
|
|
hi(as (SemBase::as))
|
|
tt(SemBase::as) member template is used. This member template is provided with
|
|
a tag value and returns the value stored inside the actual tt(Semantic)
|
|
object. Its use was shown in the previous section. Here is its
|
|
implementation:
|
|
verbinclude(//AS poly2/sembase/sembase.h)
|