Skip to content

MinMaxExpression

class MinMaxExpression

Expression representing the minimum or maximum of two sub-expressions: .min(a, b) or .max(a, b).

DEFINITION
class MinMaxExpression;

constructor MinMaxExpression

Create a minimum or maximum expression.

DEFINITION
MinMaxExpression ( const Location & location,
Expression  a,
Expression  b,
bool  minimum );
PARAMETERDESCRIPTION
location

The location of the expression in the source code.

a

The first sub-expression.

b

The second sub-expression.

minimum

Whether this is a minimum expression (true) or a maximum expression (false).

method createstatic

Create an expression representing the minimum or maximum of two sub-expressions.

This might not create a MinMaxExpression if the operation can be simplified (e.g. if both operands have values).

DEFINITION
static Expression  create ( const Location & location,
const Expression & a,
const Expression & b,
bool  minimum );
PARAMETERDESCRIPTION
location

The location of the expression in the source code.

a

The first sub-expression.

b

The second sub-expression.

minimum

Whether this is a minimum expression (true) or a maximum expression (false).

RETURNSDESCRIPTION
Expression

The created expression.

method create_maxstatic

Create a maximum expression from arguments.

DEFINITION
static Expression  create_max ( const Location & location,
const std::vector< Expression > & arguments );
PARAMETERDESCRIPTION
location

The location of the expression in the source code.

arguments

The arguments of the expression. Must contain exactly two expressions.

RETURNSDESCRIPTION
Expression

The created expression.

method create_minstatic

Create a minimum expression from arguments.

DEFINITION
static Expression  create_min ( const Location & location,
const std::vector< Expression > & arguments );
PARAMETERDESCRIPTION
location

The location of the expression in the source code.

arguments

The arguments of the expression. Must contain exactly two expressions.

RETURNSDESCRIPTION
Expression

The created expression.

method evaluatedconstvirtual

DEFINITION
virtual std::optional< Expression >  evaluated ( const EvaluationContext & context ) const;
PARAMETERDESCRIPTION
context
RETURNSDESCRIPTION
std::optional< Expression >

method maximum_valueconstvirtual

Get the maximum possible value of the expression if it can be determined.

DEFINITION
virtual std::optional< Value >  maximum_value ( ) const;
RETURNSDESCRIPTION
std::optional< Value >

The maximum possible value of the expression.

method minimum_valueconstvirtual

Get the minimum possible value of the expression if it can be determined.

DEFINITION
virtual std::optional< Value >  minimum_value ( ) const;
RETURNSDESCRIPTION
std::optional< Value >

The minimum possible value of the expression.

method serialize_subconstvirtual

Serialize the expression to a stream.

This method must be implemented by derived classes.

DEFINITION
virtual void  serialize_sub ( std::ostream & stream ) const;
PARAMETERDESCRIPTION
stream

The stream to serialize to.