PrevUpHomeNext

Concepts

Ranges
Metafunctions

This section describes concepts - named sets of requirements placed on actual types. None of the types or classes decribed in this section are actual types and none of them can be used by the library's end-user code. They are here just to describe the requirements that the types conforming to the individual concepts must satisfy in order to be considered models of those concepts. The concepts described here are also used are function parameters or return value types in this reference. In such cases the actual type is an implementation detail. If values of such types are returned from a function and need to be stored in variables, then the auto type specifier (or the decltype operator) should be used to determine the concrete type.

Range is a concept for classes, which allow simple forward traversal of elements of a specified type. As with other concepts the Range templated class does not actually exist and cannot be used in end-user code. It is used here to describe the requirements that all actual types conforming to this concept must satisfy. If this concept is used as a function return value type, then the actual type must be obtained by using the auto type specifier or with the decltype operator.

There is also a whole set of utilities for working with real types conforming to the Range concept.

template <typename Element>
class Range
{
public:
	typedef const Element ValueType; 1

	Range(const Range&); 2

	bool Empty(void) const; 3
	size_t Size(void) const; 4
	void Next(void); 5
	ValueType Front(void); 6
};

1

The type into which the value returned by Front is implicitly convertible.

2

Ranges are copyable.

3

Returns true if the range is empty.

4

Returns the number of Elements in the range.

5

This function moves the front of the range one element ahead. The range must not be empty when calling Next, otherwise the result is undefined and the application may be aborted.

6

Returns the elements at the front of the range. The range must not be empty when calling Front, otherwise the result is undefined and the application may be aborted.

A Metafunction is a compile-time metaprogramming primitive that evaluates into a type. Types modelling this concept must have a member typedef called Type - the result of the metafunction. OGLplus end-users rarely need to work with metafunctions directly, they are used mostly as internal implementation details.

struct Metafunction
{
	typedef <Unspecified> Type; 1
};

1

The result of a metafunction.


PrevUpHomeNext