|
BDE 4.14.0 Production release
|
Provide a metafunction to return an array type's element type.
bsl::remove_extentThis component provides a metafunction bsl::remove_extent that returns the element type of an array. The functionality is intended to be identical to the C++11 metafunction std::remove_extent. From the C++14 standard:
If T names a type "array of `U`", the member typedef type shall be U, otherwise T. [ Note: For multidimensional arrays, only the first array dimension is removed. For a type "array of `const U`", the resulting type is const U. – end note ]
The class template Traverser is used to traverse an array and perform some operation. In order to do its job in the case of two-dimensional arrays, Traverser must hold on to an entire row of the array at a time in order to process it correctly. The row type is determined from the array type using remove_extent :
Note that if the current compiler supports alias templates C++11 feature, we can use bsl::remove_extent_t alias to the "result" type of the bsl::remove_extent meta-function, that avoids the ::type suffix and typename prefix in the declaration of the function return type:
Now we can see that the row type is the type of the array after having striped off the high-order dimension: