This is an extension of the question asked and answered here: How to define a multiset using a function pointer?
Unfortunately I do not have enough reputation to ask the user with the accepted answer my question as a comment (9 more to go ...), so here I am. Hopefully this was OK to do.
As in that question, I am also working through C++ Primer and am up to the same section. Using the simplified example given in the link above, I'm trying to understand this line:
std::multiset<A, decltype(compareA)*> m1(compareA);
As far as I am aware, this is the syntax for copy constructors. For example, initialising a multiset of integers m1
as a copy of multiset m2
is written as std::multiset<int> m1(m2);
.
So what's going on here when we use function pointers? Is this just syntactic sugar to get the function pointer type returned by decltype(compareA)*
to point to compareA
? I think I'm fundamentally misunderstanding what this line is doing.
As a side note, how am I meant to read the documentation on std::multiset in order to answer this question? I feel like C++ documentation is much less accessible than, for instance, Java documentation, but perhaps I'm just looking in the wrong place.