The following function works in C++11:
/**
* @brief Enqueue a data item in the PQ with given priority.
*
* @param data Data item to insert into PQ
* @param priority Priority level of item
*/
void enqueueWithPriority(const T& data, const PT priority) {
size_t sizeVec = dataWithPriorityVec.size();
// push the pair of data parameters to the end of the data vector
dataWithPriorityVec.push_back(std::make_pair<const T&, const PT&>(data, priority));
// call bubble up to sort data priorities
bubbleUpHeap(sizeVec);
}
However it does not work in C++98 as I have to alter the std::make_pair
part to: std::make_pair<const T, const PT>
due to the inability to "store" references in 98. Similar syntax occurs in several other functions across my template class (where T
and PT
are generic typenames).
Is there a way I can resolve the issue such that I can use a single form of syntax as the former way works in C++11 but not 98 whereas the latter works in C++98 but not 11 - and I need to test in both environments unfortunately.
Aucun commentaire:
Enregistrer un commentaire