Concept Domain

| Home | Libraries | People | FAQ | More

## Concept Domain

Domain

## Description

A Domain creates an association between expressions and a so-called generator, which is a function that maps an expression in the default domain to an equivalent expression in this Domain. It also associates an expression with a grammar, to which all expressions within this Domain must conform.

## Associated types

- proto_grammar

      Domain::proto_grammar

  The grammar to which every expression in this Domain must conform.

- proto_generator

      Domain::proto_generator

  A Unary Polymorphic Function that accepts expressions in the default domain and emits expressions in this Domain.

- proto_super_domain

      Domain::proto_super_domain

  The Domain that is a super-domain of this domain, if any such domain exists. If not, it is some unspecified type.

- result_type

      boost::result_of<Domain(Expr)>::type

  The type of the result of applying `proto_generator` to the specified expression type. The result is required to model Expr. The domain type associated with `result_type` (`result_type::proto_domain`) is required to be the same type as this Domain.

- as_expr_result_type

      Domain::as_expr<Object>::result_type

  The result of converting some type to a Proto expression type in this domain. This is used, for instance, when calculating the type of a variable to hold a Proto expression. `as_expr_result_type` models `Expr`.

- as_child_result_type

      Domain::as_child<Object>::result_type

  The result of converting some type to a Proto expression type in this domain. This is used, for instance, to compute the type of an object suitable for storage as a child in an expression tree. `as_child_result_type` models `Expr`.

## Notation

Domain
  A type playing the role of domain-type in the Domain concept.
Expr
  A type playing the role of expression-type in the Domain concept.
Object
  A type playing the role of object-type in the Domain concept.
`d`
  Object of type Domain
`e`
  Object of type Expr
`o`
  Object of type Object

## Valid expressions

Name | Expression | Type | Semantics
--- | --- | --- | ---
Apply Generator | d(e) | result_type | The result of applying `proto_generator` to the specified expression.
As Expression | Domain::as_expr< Object >()(o) | as_expr_result_type | The result of converting some object to a Proto expression in this domain. It returns a Proto expression object that is suitable for storage in a variable. It should return a new object, which may be a copy of the object passed in.
As Child | Domain::as_child< Object >()(o) | as_child_result_type | The result of converting some object to a Proto expression in this domain. It returns an object suitable for storage as a child in an expression tree, which may simply be a reference to the object passed in.

## Models

- boost::proto::default_domain