std.range.interfaces

This module is a submodule of std.range.

The main std.range module provides template-based tools for working with ranges, but sometimes an object-based interface for ranges is needed, such as when runtime polymorphism is required. For this purpose, this submodule provides a number of object and interface definitions that can be used to wrap around range objects created by the std.range templates.

InputRangeWrapper for input ranges.
InputAssignableWrapper for input ranges with assignable elements.
ForwardRangeWrapper for forward ranges.
ForwardAssignableWrapper for forward ranges with assignable elements.
BidirectionalRangeWrapper for bidirectional ranges.
BidirectionalAssignableWrapper for bidirectional ranges with assignable elements.
RandomAccessFiniteWrapper for finite random-access ranges.
RandomAccessAssignableWrapper for finite random-access ranges with assignable elements.
RandomAccessInfiniteWrapper for infinite random-access ranges.
OutputRangeWrapper for output ranges.
OutputRangeObjectClass that implements the OutputRange interface and wraps the put methods in virtual functions.
outputRangeObjectConvenience function for creating an OutputRangeObject with a base range of type R that accepts types E.
InputRangeObjectClass that implements the InputRange interface and wraps the input range methods in virtual functions.
inputRangeObjectConvenience function for creating an InputRangeObject of the proper type.
MostDerivedInputRangeReturns the interface type that best matches the range.

Members

Classes

OutputRangeObject
class OutputRangeObject(R, E...)

Implements the OutputRange interface for all types E and wraps the put method for each type E in a virtual function.

UnsupportedRangeMethod
class UnsupportedRangeMethod

Thrown when an interface method is not supported by the wrapped range

Functions

inputRangeObject
InputRangeObject!R inputRangeObject(R range)

Convenience function for creating an InputRangeObject of the proper type. See InputRange for an example.

Interfaces

BidirectionalAssignable
interface BidirectionalAssignable(E)

Adds assignable elements to BidirectionalRange.

BidirectionalRange
interface BidirectionalRange(E)

Interface for a bidirectional range of type E.

ForwardAssignable
interface ForwardAssignable(E)

Adds assignable elements to ForwardRange.

ForwardRange
interface ForwardRange(E)

Interface for a forward range of type E.

InputAssignable
interface InputAssignable(E)

Adds assignable elements to InputRange.

InputRange
interface InputRange(E)

These interfaces are intended to provide virtual function-based wrappers around input ranges with element type E. This is useful where a well-defined binary interface is required, such as when a DLL function or virtual function needs to accept a generic range as a parameter. Note that isInputRange and friends check for conformance to structural interfaces not for implementation of these interface types.

OutputRange
interface OutputRange(E)

Interface for an output range of type E. Usage is similar to the * InputRange interface and descendants.

RandomAccessFinite
interface RandomAccessFinite(E)

Interface for a finite random access range of type E.

RandomAccessInfinite
interface RandomAccessInfinite(E)

Interface for an infinite random access range of type E.

RandomFiniteAssignable
interface RandomFiniteAssignable(E)

Adds assignable elements to RandomAccessFinite.

Templates

InputRangeObject
template InputRangeObject(R)

Implements the most derived interface that R works with and wraps all relevant range primitives in virtual functions. If R is already derived from the InputRange interface, aliases itself away.

MostDerivedInputRange
template MostDerivedInputRange(R)

Returns the interface type that best matches R.

outputRangeObject
template outputRangeObject(E...)

Convenience function for creating an OutputRangeObject with a base range * of type R that accepts types E.

Meta

Authors

Andrei Alexandrescu, David Simcha, and Jonathan M Davis. Credit for some of the ideas in building this module goes to Leonardo Maffi.