BDE 4.14.0 Production release
|
Provide utilities for operating on bdlat
"array" types.
This component provides a utility struct
, bdlat::ArrayUtil
, which serves as a namespace for a collection of function templates providing derived operations for "array" types. See bdlat_arrayfunctions for the set of requirements of "array" types in the bdlat
framework. See bdlat_typecategory for more general information about this framework.
In order to be "plugged in" to the bdlat
framework as an "array", a type must meet a set of requirements including providing certain function overloads (customization points) and specifying certain type traits, as specified by the bdlat_arrayfunctions component. We call the required function overloads the "primitive" operations of "array" types. This component provides "derived" operations, which are operations that are exclusively defined in terms of primitive operations, and as such can be used with any "array" type.
In this section we show intended usage of this component.
Suppose we would like to define a function that detects whether an element of an array is itself an array, in order to more generally detect nested arrays.
First, we need to define an accessor functor per {bdlat_typecategory |ACCESSOR
Functors} that will be used to detect whether an array element is itself an array:
Then, we can define a utility struct
, MyArrayUtil
, that provides a function for detecting whether or not an array has an element that is itself an array:
Finally, we can use this utility to detect whether elements of array types are themselves arrays: