Question: What is the return value of the C + + 2 0 function fn defined below? Binclude # include optional > #include vector > auto

What is the return value of the C++20 function fn defined below?
Binclude
# include optional>
#include vector>
auto fn (const std:: vectorint> &vec)-> std::optional (
auto iter = vec. cbegin() ;
while (iter |= vec.cend)){
if (std:: count_if (iter, vec.cend(),[iter](auto lhs)( return lhs iter; ))=0)(
+titer
continue;
}
return *iter;
}
return std: :nullopt;
}
an optional containing the largest value in the input vector, or an empty optional if the input vector is empty
an optional containing the smallest value in the input vector, or an empty optional if the input vector is empty
an optional containing the first duplicated value, or an empty optional if all elements in the input vector are unique
an optional containing the most frequently occurring value in the input vector, and never an empty optional
this function will not compile due to a syntax error

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!