dranges.traits

This module is a grab-bag of templates used by the other modules, mostly as guards by other templates (isRangeOfRanges, isTupleRange, ...).

License:
Boost License 1.0.

Authors:
Philippe Sigaud

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

template isFunctionType (F)
Returns true iff F is a function type (a function, a delegate or something definining opCall as a function).

template isFunction (alias fun)
Is true iff fun is a function/delegate or defines opCall.

template ElementTypes (R,Rest...)
Extract the element types from a variadic list of ranges.

template CommonElementType (R...) if (allSatisfy!(isInputRange,R))
Given a variadic list of ranges, find the common type to all their element types. If no common type is found, CommonElementType is void.

template CompatibleRanges (R...)
Is true iff the ranges R... have a common element type.

template allHaveLength (R,Rest...)
Is true iff all the R either have a length or are infinite.

TODO:
replace it.

template allAreInfinite (R,Rest...)
Could be replaced by allSatisfy!(isInfinite, R)?

TODO:
replace it.

template isTupleRange (R)
Is true iff R is a tuple-producing range (ie its elements are std.typecons.tuples).

template isRangeOfRanges (R)
Is true if R is a range of ranges: a (forward) range whose elements are themselves forward ranges.

template isSimpleRange (R)
Is true if R is a simple range: a (forward) range whose elements are not (forward) ranges.

template isArrayOfArrays (R)
Is true iff R is an array of arrays (ie T[][] for some T).

template isSimpleArray (R)
Is true iff R is a simple array T[] and not deeper (no U such that U[][] == T[] == R).

template rank (R) if (isSimpleRange!(R))
template rank (R) if (isRangeOfRanges!(R))
Gives the rank of an array or a range. For a simple (flat, non-nested) range of array, rank is 1. A range of ranges is depth 2 and so on... A non-range is considered to be an element and is rank 0.

Example:
int[] r1 = [0,1,2,3];
int[][] r2 = [r1, [4], r1];
int[][][] r3 = [r2, [[5,6]], r2];
assert(rank!(typeof(r1)) == 1); // No nesting, flat range
assert(rank!(typeof(r2)) == 2); // range of ranges
assert(rank!(typeof(r3)) == 3); // range of ranges of ranges


template BaseElementType (R) if (isSimpleRange!(R))
template BaseElementType (R) if (isRangeOfRanges!(R))
alias itself to the innermost type of a nested array. For example BaseElementType !(int[][][]) is int, in constrast with std.range.ElementType!(R) which would become int[][].

template BaseElementTypeUpTo (R,int maxDepth : 0) if (isForwardRange!(R))
template BaseElementTypeUpTo (R,int maxDepth = (int).max) if (isSimpleRange!(R))
template BaseElementTypeUpTo (R,int maxDepth = (int).max) if (isRangeOfRanges!(R))
Alias itself to the inner array type of a nested array, up to some maximum depth. If no maximum depth is given, it goes down to the innermost type, as BaseElementType.

Example:
int[][][][] array4;
BaseElementTypeUpTo!(typeof(array4), 0) == int[][][][]
BaseElementTypeUpTo!(typeof(array4), 1) == int[][][]
BaseElementTypeUpTo!(typeof(array4), 2) == int[][]
BaseElementTypeUpTo!(typeof(array4), 3) == int[]
BaseElementTypeUpTo!(typeof(array4))    == int


template someSatisfy (alias pred,R...)
The complementary template of std.traits.allSatisfy: is true iff some types in R satisfy predicate pred.

template Signed (T)
The complementary template of std.traits.Unsigned. Gives the signed counterpart of integral types (byte, short, int, long, char, dchar, wchar). Does nothing with floating-point types, as these are already signed. Completly based on std.traits.Unsigned.

Example:
alias TypeTuple!(int, uint, ulong, double, ushort) Test;
assert(is(staticMap!(Signed, Test) == TypeTuple!(int,int,long,double,short)));


Page was generated with on Fri Nov 12 11:55:12 2010