Mam taką deklarację funkcji składowej:
class Connection
: public protocol::packets::PacketHandler
, public util::ObserverSubject < ConnectionListener >
{
private:
std::future < protocol::packets::Packet *> CreatePacket( DataBuffer & buffer );
};
Mam taką definicję funkcji składowej:
std::future < protocol::packets::Packet *> Connection::CreatePacket( DataBuffer & buffer ) {
std::size_t readOffset = buffer.GetReadOffset();
VarInt length;
try {
buffer >> length;
} catch( const std::out_of_range & ) {
return std::future < protocol::packets::Packet *>();
}
if( length.GetInt() == 0 || buffer.GetRemaining() <( u32 ) length.GetInt() ) {
buffer.SetReadOffset( readOffset );
return std::future < protocol::packets::Packet *>();
}
DataBuffer decompressed = m_Compressor->Decompress( buffer, length.GetInt() );
return std::async( std::launch::async, & protocol::packets::PacketFactory::CreatePacket, m_Protocol, m_ProtocolState, decompressed, length.GetInt(), this );
}
Mam takie flagi:
-O2 -m64 -std=c++17 -march=native
Dostaję taki log:
||=== Build: Release Win32 in mclib (compiler: GNU GCC Compiler) ===|
C:\DISK\CODE\mclib-master\mclib\src\mclib\core\Connection.cpp||In member function 'std::future<mc::protocol::packets::Packet*> mc::core::Connection::CreatePacket(mc::DataBuffer&)':|
C:\DISK\CODE\mclib-master\mclib\src\mclib\core\Connection.cpp|256|error: no matching function for call to 'async(std::launch, mc::protocol::packets::Packet* (*)(mc::protocol::Protocol&, mc::protocol::State, mc::DataBuffer, std::size_t, mc::core::Connection*), mc::protocol::Protocol&, mc::protocol::State&, mc::DataBuffer&, s32, mc::core::Connection*)'|
C:\msys\mingw64\include\c++\7.1.0\future|1711|note: candidate: template<class _Fn, class ... _Args> std::future<typename std::result_of<typename std::decay<_Tp>::type(typename std::decay<_Args>::type ...)>::type> std::async(std::launch, _Fn&&, _Args&& ...)|
C:\msys\mingw64\include\c++\7.1.0\future|1711|note: template argument deduction/substitution failed:|
C:\DISK\CODE\mclib-master\mclib\src\mclib\core\Connection.cpp|256|required from here|
C:\msys\mingw64\include\c++\7.1.0\future|1711|error: no type named 'type' in 'class std::result_of<mc::protocol::packets::Packet* (*(mc::protocol::Protocol, mc::protocol::State, mc::DataBuffer, int, mc::core::Connection*))(mc::protocol::Protocol&, mc::protocol::State, mc::DataBuffer, long long unsigned int, mc::core::Connection*)>'|
C:\msys\mingw64\include\c++\7.1.0\future|1744|note: candidate: template<class _Fn, class ... _Args> std::future<typename std::result_of<typename std::decay<_Tp>::type(typename std::decay<_Args>::type ...)>::type> std::async(_Fn&&, _Args&& ...)|
C:\msys\mingw64\include\c++\7.1.0\future|1744|note: template argument deduction/substitution failed:|
C:\DISK\CODE\mclib-master\mclib\src\mclib\core\Connection.cpp|256|required from here|
C:\msys\mingw64\include\c++\7.1.0\future|1744|error: no type named 'type' in 'class std::result_of<std::launch(mc::protocol::packets::Packet* (*)(mc::protocol::Protocol&, mc::protocol::State, mc::DataBuffer, long long unsigned int, mc::core::Connection*), mc::protocol::Protocol, mc::protocol::State, mc::DataBuffer, int, mc::core::Connection*)>'|
||=== Build failed: 3 error(s), 2 warning(s) (0 minute(s), 13 second(s)) ===|
Wywala przy tej linijce:
return std::async( std::launch::async, & protocol::packets::PacketFactory::CreatePacket, m_Protocol, m_ProtocolState, decompressed, length.GetInt(), this );
Dlaczego to nie działa i jak to naprawić?
Co on bredzi, że nie ma jakiej funkcji wywołać?
Czy to przez przyszłe zmiany w standardzie?