First, the elements in the container (vector) are ordered. The use of container element types as built-in types is not spoken here, because it is easier.
Focus on the use of the container element type when it is a custom type. When we pass the value of the type of the data member of the custom type to the third parameter of Equal_range, I have to define a public one with the constructor for the passed-in parameter. The purpose is to make the value of the type implicitly convertible to the custom type. Therefore, a constructor with the type parameter cannot be explicit. Such as:
1 classs{2 Public:3SConst string&s) {}4 stringISBN ()5 {6 returnBookno_;7 }8 .......9 Private:Ten stringBookno_; One }; A - BOOLCompConsts& RHS,Consts&LHS) - { the returnRHS.ISBN () <LHS.ISBN (); - } - - intMain () + { -Vector<s>vec{s1,s2,....}; +Auto Range (Vec.cbegin (), Vec.cend ()," Love", comp); A ............... at}
Where "Love" is the value to be passed in comp compared to the element in Vec, but comp's formal parameter is const s& so "Love" must be able to convert to S type.
C + + standard library function Equal_range ()