J
JDT
Hi,
In the following code, is the last line safe? Do I have to check
whether p is a non-NULL pointer? I wonder if all similar STL algorithms
such as min_element, find, etc always return a non-NULL pointer (i.e. a
pointer pointing to the one after the last element) when they fail to
find what they want to find. Please advise. Thanks for your help.
int m[6];
....
int *p = std:::max_element(m, m+6);
if (p != m+6) // found something
x = *p;
Tony
In the following code, is the last line safe? Do I have to check
whether p is a non-NULL pointer? I wonder if all similar STL algorithms
such as min_element, find, etc always return a non-NULL pointer (i.e. a
pointer pointing to the one after the last element) when they fail to
find what they want to find. Please advise. Thanks for your help.
int m[6];
....
int *p = std:::max_element(m, m+6);
if (p != m+6) // found something
x = *p;
Tony