I'm getting some very odd behavior with the constructor of a class that uses a std::back_insert_iterator member variable. GCC seems to think the constructor definition is a construction call to said iterator:
Code:
../src/palace/lib/message.cpp:6:60: error: no matching function for call to 'std::back_insert_iterator<std::vector<unsigned char> >::back_insert_iterator()'
6 | PalaceMessage::PalaceMessage(std::vector<uint8_t> &incoming)
| ^
The class header itself is straightforward:
Code:
#ifndef _PALACE_MESSAGE_H
#define _PALACE_MESSAGE_H
#include <iterator>
#include <string>
#include <string_view>
#include <vector>
#include "protocol.hpp"
class _DLLEXP PalaceMessage
{
public:
PalaceMessage(std::vector<uint8_t> &incoming);
template <class T> T Get();
std::string GetCStr();
std::string GetPStr();
std::vector<uint8_t> GetData(size_t length);
template <class T> PalaceMessage& Put(T t);
PalaceMessage& PutCStr(std::string_view s);
PalaceMessage& PutPStr(std::string_view s);
PalaceMessage& PutData(const std::vector<uint8_t> &data);
private:
PALACE_MSG_HEADER m_header;
std::vector<uint8_t> m_data;
std::vector<uint8_t>::iterator m_read;
std::back_insert_iterator<std::vector<uint8_t>> m_write;
};
#endif // _PALACE_MESSAGE_H
and the constructor in the .cpp file should be a no-brainer as well:
Code:
#include <algorithm>
#include <utility>
#include "message.hpp"
PalaceMessage::PalaceMessage(std::vector<uint8_t> &incoming)
{
m_data = std::move(incoming);
m_header = Get();
}
So am I overlooking something or is GCC being a goofball?