I reviewed the RDcode code. And I come across a specific function, and I do not understand. Can you help me with this code.
template <typename T> class argless { public: argless(const T& c) : container(c) {}; // i dont understant this line. bool operator() (unsigned int v1,unsigned int v2){ return container[v1]<container[v2]; } const T &container; };
This is a constructor that references const Tand initializes a member variable containerwith it.
const T
container
It uses initialization syntax to store the container passed through the const reference in the element's variable container. It should use the initialization syntax because the container member variable is a reference (it must be initialized through a list of initializers).
constructor, .
, , .. memberOfT& operator[] (unsigned int).
memberOfT& operator[] (unsigned int)
, memberOfT bool operator<(const memberOfT&, const memberOfT&), operator(), , .
memberOfT
bool operator<(const memberOfT&, const memberOfT&)
operator()
, , T . argless , , , argless, argless.
T
argless
:
1) .
2) .
It is used so that the operator () can act as the <operator for the components of another container. You would use it to sort one container based on the contents of another, where the first contains indexes in the second. In this case, you will find out what a sorted container looks like without having to sort it - a useful thing if moving items around is expensive or impossible, such as strings.
Source: https://habr.com/ru/post/1769891/More articles:Get offset of node in whole html document in Javascript? - javascriptКак вставить в поле ForeignKey с использованием необработанного SQL? - sqlAPI development guidelines - apiInteraction coordination: onStop and onResume - androidRemove Emacs Selection - emacsSharing a sensory sequence between multiple instances of UIGestureRecognizer - iospython 2to3 manual modification - pythonСделать диалог привязки ViewModel готовым, вызвать Dialog и вернуть данные из него в MVVM - callbackCalculating the distribution of a hash function for a hash map that uses a chain - c ++Approach to bottlenecks in code - javaAll Articles