Ошибка при назначении контейнера (std :: vector) на std :: priority_queueC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Ошибка при назначении контейнера (std :: vector) на std :: priority_queue

Сообщение Anonymous »

Я реализую решение из сообщения: https://stackoverflow.com/a/79433983/6319901 в моем коде.

OS разработка: Ubuntu 24.04 LTS.

My Target OS: vxworks 7

language: c ++ 17
< /p>
Я получаю упомянутую ошибку. br /> Контейнер < /p>
std::vector container;
< /code>
Ошибка оператора: < /p>
std::priority_queue mReceiveDataQueue ( {}, std::move(this->container));
< /code>
IPC Constructor < /p>
Ipc()
{
container.reserve(max_message_depth);
}
< /code>
code: < /p>
P>ipc.hpp
#pragma once

#include
#include
#include
#include
#include
#include
#include
#include //For callback
#include //Definition of SIGEV_* constants
#include //For O_RDWR, O_RDONLY, O_WRONLY constants
#include //For mode constants
#include //For POSIX Message Queue
#include
#include
#include

#ifdef __linux__
std::string errorToString(error_t errorNumber)
#else
std::string errorToString(errno_t errorNumber)
#endif
{
const std::uint16_t errorStringLength{1024};
char errorDataCharArray[errorStringLength];
#ifdef __linux__
std::strncpy(errorDataCharArray,
::strerror_l(errno, ::uselocale((locale_t)0)),
errorStringLength);
#else
strerror_s(errorDataCharArray, errorStringLength, errno);
#endif
std::string errorString(errorDataCharArray);
return errorString;
}

template
class Ipc
{
private:

typedef struct ipc_receive
{
std::uint32_t priority;
T2 data;
bool operator>(const ipc_receive& object) const //Check if greater
{
return this->priority < object.priority;
}
}ipc_receive_t;
std::vector container;

using callback_t = std::function;
callback_t mCallback;

//Message Queue file descriptor
mqd_t mPrimaryToSecondaryMessageQueue {-1};
mqd_t mSecondaryToPrimaryMessageQueue {-1};

std::string mPrimaryToSecondaryMessageQueueName;
std::string mSecondaryToPrimaryMessageQueueName;

mutable std::mutex mReceiveMutex;

std::priority_queue mReceiveDataQueue ( {}, std::move(this->container));
//bool listen(void);
void listen(void);
public:
Ipc()
{
container.reserve(max_message_depth);
}
};

template
//inline bool Ipc::listen(void)
inline void Ipc::listen(void)
{
mqd_t mqFd;
ipc_receive_t ipc_receive;
if(primaryNode == true) //Select secondaryToPrimaryQueue queue to receieve data in primary mode
{
mqFd = this->mSecondaryToPrimaryMessageQueue;
}
else //Select primaryToSecondary queue to receive data in non-primary mode (secondary mode)
{
mqFd = this->mPrimaryToSecondaryMessageQueue;
}
while(true)
{
ssize_t receiveLength = mq_receive(
mqFd,
reinterpret_cast(&ipc_receive.data),
sizeof(ipc_receive.data),
&ipc_receive.priority
);

if(receiveLength == -1)
{
std::cout container));
| ^

ipc.hpp:67:116: error: expected ‘)’ before ‘{’ token
67 | std::priority_queue mReceiveDataQueue ( {}, std::move(this->container));
| ~^~
| )
ipc.hpp:67:119: error: expected unqualified-id before ‘,’ token
67 | std::priority_queue mReceiveDataQueue ( {}, std::move(this->container));
| ^

ipc.hpp: In member function ‘void Ipc::listen()’:
ipc.hpp:109:31: error: invalid use of member function ‘std::priority_queue Ipc::mReceiveDataQueue(int)’ (did you forget the ‘()’ ?)
109 | this->mReceiveDataQueue.push(ipc_receive);


Подробнее здесь: https://stackoverflow.com/questions/794 ... rity-queue
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»