First of all, I'm a C++ novice so be gentle. In my cross-platform project I've run into an issue I can't sort out using VS Studio 2019 via the nar builder in Maven. The build works a-ok on Linux, but on Windows 10 x64 the build fails here:
[ERROR] OUTPUT>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include\any(429): error C2338: any_cast<T>(any&&) requires T to be constructible from remove_cv_t<remove_reference_t<T>>
[INFO] OUTPUT>c++/SRTServer.cpp(188): note: see reference to function template instantiation '_Ty &std::any_cast<std::shared_ptr<NetworkConnection>&>(std::any &&)' being compiled
[INFO] OUTPUT> with
[INFO] OUTPUT> [
[INFO] OUTPUT> _Ty=std::shared_ptr<NetworkConnection> &
[INFO] OUTPUT> ]
The NetworkConnection is in an included h file and consists of
class NetworkConnection {
public:
NetworkConnection();
virtual ~NetworkConnection();
std::any object;
uint16_t connectorId;
};
Lines 183-193 of SRTServer.cpp
void gotData(ElasticFrameProtocol::pFramePtr &rPacket) {
std::cout << "Got NAL-units of size " << unsigned(rPacket->mFrameSize) <<
" pts " << unsigned(rPacket->mPts) << " is broken? " << rPacket->mBroken <<
" from EFP connection " << unsigned(rPacket->mSource) << std::endl;
// TODO the NetworkConnection must be looked up to get the server id and client id
auto nc = std::any_cast<std::shared_ptr<NetworkConnection> &>(rPacket->mSource); // the source being a NetworkConnection is a guess right now
// get the client from the network connection
auto client = std::any_cast<std::shared_ptr<Client> &>(nc->object);
// call the receive method
recvData(rPacket->pFrameData, rPacket->mFrameSize, client->serverId, client->connectorId, rPacket->mStream);
}
As mentioned in the comments the casting of mSource (uint8_t) to a NetworkConnection (Class) will fail. And as you say -> // the source being a NetworkConnection is a guess right now
.
There is probably another part of the code where you should do the casting. If more code is provided then we can help.
/Anders
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.