chsvlib
chsv helper source code

◆ make_raw_pointer_iterator()

constexpr raw_pointer_iterator<T*> Chusov::Memory::make_raw_pointer_iterator ( T *  ptr,
std::size_t  cSize,
typename raw_pointer_iterator< T * >::difference_type  iOffset 
)
constexprnoexcept

The function for creation iterators, which, in essence, are raw pointers, that has an interface compatible with Microsoft stdext::checked_array_iterator.

Template Parameters
Tis a type of a value of a raw pointer to be adapted to the raw_pointer_iterator<T*> type.
Parameters
ptris a pointer to be adapted.
cSizeis a size of data or buffer pointed to by ptr, in elements of the T type. The size is passed to the checked_array_iterator class by the function when the build is performed by an MSVC compiler with defined _SECURE_SCL macro. Otherwise, the parameter is ignored.
iOffsetis an offset within the buffer pointed to by ptr, in elements of the T type. The iterator is associated with an element ptr[iOffset]. Similar to cSize, the offset is passed to the checked_array_iterator, if the compiler used is MSVC, or added to ptr to produce the returned pointer otherwise.
Returns
Returns an object of the raw_pointer_iterator type. This type is defined as checked_array_iterator when this file is compiled with Microsoft Visual C++ so that no C4996 warning is generated.

Other compilers consider the returned value as a pointer which equals ptr.