Could you help me to understand the code below? I have an interface and need to write a code. But it first time when I work with OOP. I would be grateful if you answer some questions about this code.
template <class T, class Compare = std::less<T>>
class List_of_objects {
public:
using IndexChange =
std::function<void(const T& element, size_t new_element_index)>;
explicit Heap(
Compare compare = Compare(),
IndexChange index_change = IndexChange());
// Other methods not important in my question
private:
IndexChange index_change_;
Compare compare_;
}
// Realization of methods
template<class T, class Compare>
List_of_objects<T, Compare>::List_of_objects(Compare compare, IndexChange index_change)
: compare_(compare), index_change_(index_change) {}
I have learned what std::function<>
do from this site but I don't understand why we are writing using
before 'IndexChange'
Also I have no idea what does compare_(compare)
means, and what mean single colon in realization of List_of_objects()
I think that it is not difficult questions but I meet a deadline, I can't find answers in Stroustrup and in i-net:(
Thank you for any help!