View Template Library


Invertible Function

Category: functors

Component type: concept

Description

An Invertible Function is a kind of function object: an object that is called as if it were an ordinary C++ function and provides an inverse [2]. An Invertible Function is called with a single argument.

Refinement of

UnaryFunction

Associated types

Argument type

The type of the Unary Function's argument.

Result type

The type returned when the Unary Function is called

Notation

F

A type that is a model of Unary Function

X

The argument type of F

Result

The result type of F

f

Object of type F

x

Object of type X

Definitions

The domain of a Unary Function is the set of all permissible values for its argument.

The range of a Unary Function is the set of all possible values that it may return.

Valid expressions

Name

Expression

Type requirements

Return type

Function call

f(x)

 

Result

Inverse call

f.inverse(r)


X

Expression semantics

Name

Expression

Precondition

Semantics

Postcondition

Function call

f(x)

x is in f's domain

Calls f with x as an argument, and returns a value of type Result [1]

The return value is in f's range

Inverse call

f.inverse(r)

r is in f's range

Calls f.inverse with r as an argument and returns a value of type X

The return value is in f's domain.

Complexity guarantees

Invariants

Models

Notes

[1] Two different invocations of f may return different results, even if f is called with the same arguments both times. A Unary Function may refer to local state, perform I/O, and so on. The expression f(x) is permitted to change f's state.

[2] The inverse method an Invertible Function provides does not need to satisfy the usual invariants f.inverse(f(x))==x and f(f.inverse(r))==r. This guarantee is provided by suitable refinements. Nevertheless, the name intentionally suggests some similar property. This should be kept in mind implementing Invertible Functions.

See also

Function Object overview, Generator, Binary FunctionAdaptable Unary Function



Copyright © 1999 Silicon Graphics, Inc. All Rights Reserved.TrademarkInformation